{"id":49545,"date":"2024-12-03T13:10:25","date_gmt":"2024-12-03T05:10:25","guid":{"rendered":"https:\/\/fwq.ai\/blog\/49545\/"},"modified":"2024-12-03T13:10:25","modified_gmt":"2024-12-03T05:10:25","slug":"%e4%b8%ba%e4%bb%80%e4%b9%88%e6%88%91%e7%9a%84python%e7%8c%9c%e6%95%b0%e5%ad%97%e6%b8%b8%e6%88%8f%e5%9c%a8%e6%a1%8c%e9%9d%a2%e8%bf%90%e8%a1%8c%e6%97%b6%e6%97%a0%e6%b3%95%e6%98%be%e7%a4%ba%e7%bb%93","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/49545\/","title":{"rendered":"\u4e3a\u4ec0\u4e48\u6211\u7684Python\u731c\u6570\u5b57\u6e38\u620f\u5728\u684c\u9762\u8fd0\u884c\u65f6\u65e0\u6cd5\u663e\u793a\u7ed3\u679c\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u4e3a\u4ec0\u4e48\u6211\u7684Python\u731c\u6570\u5b57\u6e38\u620f\u5728\u684c\u9762\u8fd0\u884c\u65f6\u65e0\u6cd5\u663e\u793a\u7ed3\u679c\uff1f<\/h1>\n<p>\u4eb2\u7231\u7684\u7f16\u7a0b\u5b66\u4e60\u7231\u597d\u8005\uff0c\u5982\u679c\u4f60\u70b9\u5f00\u4e86\u8fd9\u7bc7\u6587\u7ae0\uff0c\u8bf4\u660e\u4f60\u5bf9\u300a\u4e3a\u4ec0\u4e48\u6211\u7684Python\u731c\u6570\u5b57\u6e38\u620f\u5728\u684c\u9762\u8fd0\u884c\u65f6\u65e0\u6cd5\u663e\u793a\u7ed3\u679c\uff1f\u300b\u5f88\u611f\u5174\u8da3\u3002\u672c\u7bc7\u6587\u7ae0\u5c31\u6765\u7ed9\u5927\u5bb6\u8be6\u7ec6\u89e3\u6790\u4e00\u4e0b\uff0c\u4e3b\u8981\u4ecb\u7ecd\u4e00\u4e0b\uff0c\u5e0c\u671b\u6240\u6709\u8ba4\u771f\u8bfb\u5b8c\u7684\u7ae5\u978b\u4eec\uff0c\u90fd\u6709\u5b9e\u8d28\u6027\u7684\u63d0\u9ad8\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241026\/1729943506671cd7d2c0ecb.jpg\" class=\"aligncenter\" title=\"\u4e3a\u4ec0\u4e48\u6211\u7684Python\u731c\u6570\u5b57\u6e38\u620f\u5728\u684c\u9762\u8fd0\u884c\u65f6\u65e0\u6cd5\u663e\u793a\u7ed3\u679c\uff1f\u63d2\u56fe\" alt=\"\u4e3a\u4ec0\u4e48\u6211\u7684Python\u731c\u6570\u5b57\u6e38\u620f\u5728\u684c\u9762\u8fd0\u884c\u65f6\u65e0\u6cd5\u663e\u793a\u7ed3\u679c\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>idle shell3.10.6\u4e0a\u7684\u7a0b\u5e8f\u5728\u684c\u9762\u8fd0\u884c\u4e0d\u5b8c\u6574<\/strong><\/p>\n<p>\u4e00\u4e2a\u5165\u95e8\u65b0\u624b\u9047\u5230\u5982\u4e0b\u95ee\u9898\uff1a<\/p>\n<pre>import random\n\nsecret = random.randint(1,  20)\ntemp = input(\"\u731c\u6570\u5b57\uff1a\")\nguess = int(temp)\ntime = 1\nwhile (guess != secret)  and  (time &lt; 3):\n    if guess &gt; secret:\n        print(\"too big\")\n    else:\n        print(\"too small\")\n\n    temp = input(\"again:\")\n    guess = int(temp)\n    time = time + 1\n\nif time &lt; 3:\n   print(\"ture\")\nelse:\n     print(\"no more chance\")\n     print(\"answer is \" + str(secret))<\/pre>\n<p>\u8fd9\u4e2a\u7a0b\u5e8f\u5728idle\u4e0a\u53ef\u4ee5\u6b63\u5e38\u8fd0\u884c\uff0c\u4f46\u5728\u684c\u9762\u8fd0\u884c\u65f6\u4f1a\u8fd0\u884c\u4e0d\u5b8c\u6574\uff0c\u6309\u4e0benter\u540e\u81ea\u52a8\u5173\u95ed\uff0c\u65e0\u6cd5\u663e\u793a\u6700\u540e\u7684\u7ed3\u679c\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848\uff1a<\/strong><\/p>\n<ul>\n<li><strong>\u52a0\u5165\u903b\u8f91\u505c\u987f\uff1a<\/strong>\u8ba1\u7b97\u51fa\u7ed3\u679c\u540e\uff0c\u6dfb\u52a0\u4e00\u884c\u4ee3\u7801\uff0c\u4f8b\u5982time.sleep(5)\uff0c\u8ba9\u7a0b\u5e8f\u505c\u987f5\u79d2\u949f\u540e\u518d\u9000\u51fa\u3002<\/li>\n<li><strong>\u4f7f\u7528\u547d\u4ee4\u884c\u6267\u884c\uff1a<\/strong>\u542f\u52a8\u4e00\u4e2acmd\u7a97\u53e3\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1apython [\u6587\u4ef6\u8def\u5f84]\u3002\u8fd9\u6837\u53ef\u4ee5\u907f\u514didle\u7684\u81ea\u52a8\u5173\u95ed\u95ee\u9898\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u300a\u4e3a\u4ec0\u4e48\u6211\u7684Python\u731c\u6570\u5b57\u6e38\u620f\u5728\u684c\u9762\u8fd0\u884c\u65f6\u65e0\u6cd5\u663e\u793a\u7ed3\u679c\uff1f\u300b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u5173\u4e8e\u7684\u8d44\u6599\u8bf7\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e3a\u4ec0\u4e48\u6211\u7684Python\u731c\u6570\u5b57\u6e38\u620f\u5728\u684c\u9762\u8fd0\u884c\u65f6\u65e0\u6cd5\u663e\u793a\u7ed3\u679c\uff1f \u4eb2\u7231\u7684\u7f16\u7a0b\u5b66\u4e60\u7231\u597d\u8005\uff0c\u5982\u679c\u4f60\u70b9\u5f00\u4e86\u8fd9\u7bc7\u6587\u7ae0\uff0c\u8bf4\u660e\u4f60\u5bf9\u300a\u4e3a\u4ec0\u4e48\u6211\u7684Python\u731c\u6570\u5b57\u6e38\u620f\u5728\u684c\u9762\u8fd0\u884c\u65f6\u65e0\u6cd5\u663e\u793a\u7ed3\u679c\uff1f\u300b\u5f88\u611f\u5174\u8da3\u3002\u672c\u7bc7\u6587\u7ae0\u5c31\u6765\u7ed9\u5927\u5bb6\u8be6\u7ec6\u89e3\u6790\u4e00\u4e0b\uff0c\u4e3b\u8981\u4ecb\u7ecd\u4e00\u4e0b\uff0c\u5e0c\u671b\u6240\u6709\u8ba4\u771f\u8bfb\u5b8c\u7684\u7ae5\u978b\u4eec\uff0c\u90fd\u6709\u5b9e\u8d28\u6027\u7684\u63d0\u9ad8\u3002 idle shell3.10.6\u4e0a\u7684\u7a0b\u5e8f\u5728\u684c\u9762\u8fd0\u884c\u4e0d\u5b8c\u6574 \u4e00\u4e2a\u5165\u95e8\u65b0\u624b\u9047\u5230\u5982\u4e0b\u95ee\u9898\uff1a import random secret = random.randint(1, 20) temp = input(&#8220;\u731c\u6570\u5b57\uff1a&#8221;) guess = int(temp) time = 1 while (guess != secret) and (time &lt; 3): if guess &gt; secret: print(&#8220;too big&#8221;) else: print(&#8220;too small&#8221;) temp = input(&#8220;again:&#8221;) guess = int(temp) time = time + 1 if time &lt; 3: print(&#8220;ture&#8221;) else: print(&#8220;no [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-49545","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49545","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=49545"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49545\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=49545"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=49545"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=49545"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}