{"id":137922,"date":"2019-02-28T10:19:57","date_gmt":"2019-02-28T02:19:57","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=137922"},"modified":"2019-02-25T10:23:41","modified_gmt":"2019-02-25T02:23:41","slug":"rock-paper-scissors","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/rock-paper-scissors.html","title":{"rendered":"Python\u526a\u5200\u77f3\u5934\u5e03\u6e38\u620f"},"content":{"rendered":"
\r\n#!\/urs\/bin\/env python\r\nimport random\r\n\r\nall_choice = ['\u77f3\u5934','\u526a\u5200','\u5e03']\r\nwin_list = [['\u77f3\u5934','\u526a\u5200'],['\u526a\u5200','\u5e03'],['\u5e03','\u77f3\u5934']]\r\nprompt = \"\"\"\r\n(0) \u77f3\u5934\r\n(1) \u526a\u5200\r\n(2) \u5e03\r\nPlease input your choice(0\/1\/2): \"\"\"\r\n\r\ncomputer = random.choice(all_choice)\r\nind = int(input(prompt))\r\nplayer = all_choice[ind]\r\n\r\nprint(\"Your choice: %s,Computer's choice: %s\" %(player,computer))\r\nif player == computer:\r\n print('\\033[32;1m\u5e73\u5c40\\033[0m')\r\nelif [player,computer] in win_list:\r\n print('\\033[31;1mYou WIN!!!\\033[0m')\r\nelse:\r\n print('\\033[31;1mYou LOSE!!!\\033[0m')\r\n<\/pre>\n\u6f14\u793a<\/strong><\/div>\n\r\nD:\\Python scripts \r\n\u03bb python3 .\\srpgame.py \r\n \r\n(0) \u77f3\u5934 \r\n(1) \u526a\u5200 \r\n(2) \u5e03 \r\nPlease input your choice(0\/1\/2): 0 \r\nYour choice: \u77f3\u5934,Computer's choice: \u526a\u5200 \r\nYou WIN!!! \r\nD:\\Python scripts \r\n\u03bb python3 .\\srpgame.py \r\n \r\n(0) \u77f3\u5934 \r\n(1) \u526a\u5200 \r\n(2) \u5e03 \r\nPlease input your choice(0\/1\/2): 1 \r\nYour choice: \u526a\u5200,Computer's choice: \u526a\u5200 \r\n\u5e73\u5c40 \r\nD:\\Python scripts \r\n\u03bb python3 .\\srpgame.py \r\n \r\n(0) \u77f3\u5934 \r\n(1) \u526a\u5200 \r\n(2) \u5e03 \r\nPlease input your choice(0\/1\/2): 2 \r\nYour choice: \u5e03,Computer's choice: \u77f3\u5934 \r\nYou WIN!!! \r\nD:\\Python scripts \r\n\u03bb python3 .\\srpgame.py \r\n \r\n(0) \u77f3\u5934 \r\n(1) \u526a\u5200 \r\n(2) \u5e03 \r\nPlease input your choice(0\/1\/2): 0 \r\nYour choice: \u77f3\u5934,Computer's choice: \u5e03 \r\nYou LOSE!!! \r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"#!\/urs\/bin\/env python import random all_choice = [‘\u77f3\u5934’, […]<\/p>\n","protected":false},"author":63,"featured_media":137923,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-137922","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/137922","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=137922"}],"version-history":[{"count":2,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/137922\/revisions"}],"predecessor-version":[{"id":138105,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/137922\/revisions\/138105"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/137923"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=137922"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=137922"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=137922"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}