{"id":303,"date":"2020-03-21T07:25:44","date_gmt":"2020-03-20T23:25:44","guid":{"rendered":"https:\/\/jingran.vip\/?p=303"},"modified":"2020-03-21T07:25:44","modified_gmt":"2020-03-20T23:25:44","slug":"%e9%9b%b6%e5%9f%ba%e7%a1%80%e5%85%a5%e9%97%a8%e5%ad%a6%e4%b9%a0python-%e5%ad%a6%e4%b9%a0%e7%ac%94%e8%ae%b0%ef%bc%88%e5%85%ad%ef%bc%89%e6%94%b9%e8%bf%9b%e6%88%91%e4%bb%ac%e7%9a%84%e5%b0%8f","status":"publish","type":"post","link":"https:\/\/jingran.vip\/index.php\/2020\/03\/21\/%e9%9b%b6%e5%9f%ba%e7%a1%80%e5%85%a5%e9%97%a8%e5%ad%a6%e4%b9%a0python-%e5%ad%a6%e4%b9%a0%e7%ac%94%e8%ae%b0%ef%bc%88%e5%85%ad%ef%bc%89%e6%94%b9%e8%bf%9b%e6%88%91%e4%bb%ac%e7%9a%84%e5%b0%8f\/","title":{"rendered":"\u96f6\u57fa\u7840\u5165\u95e8\u5b66\u4e60Python \u2013 \u5b66\u4e60\u7b14\u8bb0\uff08\u516d\uff09\u6539\u8fdb\u6211\u4eec\u7684\u5c0f\u6e38\u620f\uff08\u4e0b\uff09"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>\"\"\"\u7528Python\u8bbe\u8ba1\u7b2c\u4e00\u4e2a\u6e38\u620f\"\"\"\n\ncounts = 3\nwhile counts > 0:\n    temp = input(\"\u4e0d\u59a8\u731c\u4e00\u4e0b\u6211\u73b0\u5728\u5fc3\u91cc\u60f3\u7684\u662f\u54ea\u4e2a\u6570\u5b57\uff1f\")\n    guess = int(temp)\n\n    if guess == 8:\n        print(\"\u4f60\u662f\u6211\u5fc3\u91cc\u7684\u86d4\u866b\u561b\uff1f\")\n        print(\"\u54fc\uff0c\u731c\u4e2d\u4e86\u4e5f\u6ca1\u5956\u52b1\")\n        break\n    else:\n        if guess &lt; 8:\n            print(\"\u5c0f\u5566\uff01\")\n        else:\n            print(\"\u5927\u5566\uff01\")\n    counts = counts -1\n\nprint(\"\u6e38\u620f\u7ed3\u675f,\u4e0d\u73a9\u5566^_^\")<\/code><\/pre>\n\n\n\n<p>\u7b54\u6848\u5982\u4f55\u968f\u673a\uff1f<\/p>\n\n\n\n<p>\u4f2a\u968f\u673a\u6570 random\u6a21\u5757<\/p>\n\n\n\n<p>IDLE-Help-\u7d22\u5f15-\u8f93\u5165\u67e5\u627e\u5173\u952e\u5b57 \u67e5\u627e\u6a21\u5757\u4f5c\u7528<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import random<\/code><\/pre>\n\n\n\n<p>\u5bfc\u5165\u6a21\u5757 import \u6a21\u5757<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import random\nrandom.randint(1,10)<\/code><\/pre>\n\n\n\n<p>Alt+P\u91cd\u590d\u4e0a\u4e00\u6761\u8bed\u53e5<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\"\"\"\u7528Python\u8bbe\u8ba1\u7b2c\u4e00\u4e2a\u6e38\u620f\"\"\"\nimport random\n\ncounts = 3\nanswer = random.randint(1,10)\nwhile counts > 0:\n    temp = input(\"\u4e0d\u59a8\u731c\u4e00\u4e0b\u6211\u73b0\u5728\u5fc3\u91cc\u60f3\u7684\u662f\u54ea\u4e2a\u6570\u5b57\uff1f\")\n    guess = int(temp)\n\n    if guess == answer:\n        print(\"\u4f60\u662f\u6211\u5fc3\u91cc\u7684\u86d4\u866b\u561b\uff1f\")\n        print(\"\u54fc\uff0c\u731c\u4e2d\u4e86\u4e5f\u6ca1\u5956\u52b1\")\n        break\n    else:\n        if guess &lt; answer:\n            print(\"\u5c0f\u5566\uff01\")\n        else:\n            print(\"\u5927\u5566\uff01\")\n    counts = counts -1\n\nprint(\"\u6e38\u620f\u7ed3\u675f,\u4e0d\u73a9\u5566^_^\")<\/code><\/pre>\n\n\n\n<p>\u968f\u673a\u6570\u79cd\u5b50\uff1f<\/p>\n\n\n\n<p>random.getstate()<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>x = random.getstate()\nrandom.randint(1,10)<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>random.setstate(x)<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7b54\u6848\u5982\u4f55\u968f\u673a\uff1f \u4f2a\u968f\u673a\u6570 random\u6a21\u5757 IDLE-Help-\u7d22\u5f15-\u8f93\u5165\u67e5\u627e\u5173\u952e\u5b57 \u67e5\u627e\u6a21\u5757\u4f5c\u7528  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":190,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,10],"tags":[],"_links":{"self":[{"href":"https:\/\/jingran.vip\/index.php\/wp-json\/wp\/v2\/posts\/303"}],"collection":[{"href":"https:\/\/jingran.vip\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jingran.vip\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jingran.vip\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jingran.vip\/index.php\/wp-json\/wp\/v2\/comments?post=303"}],"version-history":[{"count":1,"href":"https:\/\/jingran.vip\/index.php\/wp-json\/wp\/v2\/posts\/303\/revisions"}],"predecessor-version":[{"id":304,"href":"https:\/\/jingran.vip\/index.php\/wp-json\/wp\/v2\/posts\/303\/revisions\/304"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/jingran.vip\/index.php\/wp-json\/wp\/v2\/media\/190"}],"wp:attachment":[{"href":"https:\/\/jingran.vip\/index.php\/wp-json\/wp\/v2\/media?parent=303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jingran.vip\/index.php\/wp-json\/wp\/v2\/categories?post=303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jingran.vip\/index.php\/wp-json\/wp\/v2\/tags?post=303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}