{"id":2374,"date":"2022-12-10T10:04:11","date_gmt":"2022-12-10T02:04:11","guid":{"rendered":"https:\/\/qaqaq.top\/?p=2374"},"modified":"2023-01-10T22:02:32","modified_gmt":"2023-01-10T14:02:32","slug":"python%e6%8e%a7%e5%88%b6%e5%8f%b0%e6%b5%8b%e5%89%8d%e4%b8%96%e6%b8%b8%e6%88%8f","status":"publish","type":"post","link":"https:\/\/qaqaq.top\/?p=2374","title":{"rendered":"python \u63a7\u5236\u53f0 \u6d4b\u524d\u4e16\u6e38\u620f"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>\nimport random\n\n\n# \u524d\u4e16\nclass PastLife:\n    def __init__(self, name, profession, life, causeOfDeath):\n        self.name = name\n        self.profession = profession\n        self.life = life\n        self.causeOfDeath = causeOfDeath\n\n    def __str__(self):\n        return \"\u60a8\u7684\u524d\u4e16\u662f\" + self.profession + self.name + \"\u6d3b\u4e86\" + str(\n            self.life) + \"\u5c81.\u60a8\u524d\u4e16\u6b7b\u4e8e\" + self.causeOfDeath\n\n\n# \u4eca\u751f\nclass ThisLife:\n    def __init__(self, name, sex):\n        self.name = name\n        self.sex = sex\n\n    # \u7a7f\u8d8a\n    def passThrough(self):\n        i = random.randint(0, 3)\n        if i == 0:\n            pastLife = PastLife(\"\u5b59\u5c1a\u9999\", \"\u90e1\u4e3b\", 64, \"\u81ea\u5c3d\")\n        elif i == 1:\n            pastLife = PastLife(\"\u5f20\u98de\", \"\u8f66\u9a91\u5c06\u519b\", 53, \"\u8c0b\u6740\")\n        elif i == 2:\n            pastLife = PastLife(\"\u8bf8\u845b\u4eae\", \"\u5b54\u660e\u5148\u751f\", 60, \"\u6c14\u6b7b\")\n        else:\n            pastLife = PastLife(\"\u8340\u5f67\", \"\u5927\u806a\u660e\", 57, \"\u8001\u6b7b\")\n        return pastLife\n\n\ndef main():\n    thisLife = ThisLife(input(\"\u8bf7\u8f93\u5165\u4f60\u7684\u59d3\u540d\uff1a\"), input(\"\u8bf7\u8f93\u5165\u60a8\u7684\u6027\u522b(\u7537\u6216\u5973)\uff1a\"))\n    p = thisLife.passThrough()\n    print(\"\u5929\u7075\u7075\uff01\u5730\u7075\u7075\uff01\u592a\u4e0a\u8001\u541b\u6025\u6025\u5982\u5f8b\u4ee4......\", p)\n\n\nmain()\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[65],"tags":[50],"class_list":["post-2374","post","type-post","status-publish","format-standard","hentry","category-python-code","tag-python"],"_links":{"self":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/2374"}],"collection":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2374"}],"version-history":[{"count":2,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/2374\/revisions"}],"predecessor-version":[{"id":3530,"href":"https:\/\/qaqaq.top\/index.php?rest_route=\/wp\/v2\/posts\/2374\/revisions\/3530"}],"wp:attachment":[{"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2374"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qaqaq.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}