{"id":204118,"date":"2025-05-29T09:38:16","date_gmt":"2025-05-29T01:38:16","guid":{"rendered":"https:\/\/server.hk\/cnblog\/204118\/"},"modified":"2025-05-29T09:38:16","modified_gmt":"2025-05-29T01:38:16","slug":"python-%e4%bc%91%e7%9c%a0%e6%9c%9f%e9%97%b4%e5%a6%82%e4%bd%95%e6%89%a7%e8%a1%8c%e5%85%b6%e4%bb%96%e6%93%8d%e4%bd%9c%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/204118\/","title":{"rendered":"Python \u4f11\u7720\u671f\u95f4\u5982\u4f55\u6267\u884c\u5176\u4ed6\u64cd\u4f5c\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>Python \u4f11\u7720\u671f\u95f4\u5982\u4f55\u6267\u884c\u5176\u4ed6\u64cd\u4f5c\uff1f<\/h1>\n<p>\u4f60\u5728\u5b66\u4e60\u76f8\u5173\u7684\u77e5\u8bc6\u5417\uff1f\u672c\u6587<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aPython \u4f11\u7720\u671f\u95f4\u5982\u4f55\u6267\u884c\u5176\u4ed6\u64cd\u4f5c\uff1f\u300b<\/span>\uff0c\u4e3b\u8981\u4ecb\u7ecd\u7684\u5185\u5bb9\u5c31\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\uff0c\u5982\u679c\u4f60\u60f3\u63d0\u5347\u81ea\u5df1\u7684\u5f00\u53d1\u80fd\u529b\uff0c\u5c31\u4e0d\u8981\u9519\u8fc7\u8fd9\u7bc7\u6587\u7ae0\uff0c\u5927\u5bb6\u8981\u77e5\u9053\u7f16\u7a0b\u7406\u8bba\u57fa\u7840\u548c\u5b9e\u6218\u64cd\u4f5c\u90fd\u662f\u4e0d\u53ef\u6216\u7f3a\u7684\u54e6\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241028\/1730123509671f96f52946d.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>python \u5728\u4f11\u7720\u671f\u95f4\u4e5f\u80fd\u5fd9\u5176\u4ed6\u4e8b\uff1f<\/strong><\/p>\n<p>\u5728\u7ed9\u5b9a\u7684\u4ee3\u7801\u7247\u6bb5\u4e2d\uff0ctimes() \u51fd\u6570\u4f7f\u7528 time.sleep(7200) \u4f11\u7720 7200 \u79d2\uff0c\u5728\u8fd9\u4e2a\u4f11\u7720\u671f\u95f4\uff0c\u8be5\u51fd\u6570\u65e0\u6cd5\u6267\u884c\u5176\u4ed6\u4efb\u4f55\u64cd\u4f5c\u3002<\/p>\n<p>\u4f46\u662f\uff0c\u5982\u679c\u4f60\u9700\u8981\u5728\u7b49\u5f85\u671f\u95f4\u6bcf\u9694\u4e00\u5b9a\u65f6\u95f4\u6267\u884c\u5176\u4ed6\u64cd\u4f5c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u6cd5\uff1a<\/p>\n<p>\u9996\u5148\uff0c\u521b\u5efa\u4e00\u4e2a\u8f85\u52a9\u51fd\u6570\uff0c\u5982 _dosth()\uff0c\u6765\u6267\u884c\u9700\u8981\u6bcf\u9694\u4e00\u5b9a\u65f6\u95f4\u6267\u884c\u7684\u64cd\u4f5c\u3002<\/p>\n<p>\u7136\u540e\uff0c\u5728 times() \u51fd\u6570\u4e2d\uff0c\u4f7f\u7528 for \u5faa\u73af\u6765\u8c03\u7528 _dosth() \u51fd\u6570\u6307\u5b9a\u6b21\u6570\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>for i in range(120):\n    _dosth()\n    time.sleep(60)<\/pre>\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c_dosth() \u51fd\u6570\u5c06\u5728 7200 \u79d2\u7684\u4f11\u7720\u671f\u95f4\u6bcf 60 \u79d2\u8c03\u7528\u4e00\u6b21\u3002<\/p>\n<p>\u8fd9\u6837\uff0c\u4f60\u5c31\u53ef\u4ee5\u5728 times() \u51fd\u6570\u4f11\u7720\u671f\u95f4\u6267\u884c\u5176\u4ed6\u64cd\u4f5c\uff0c\u800c\u65e0\u9700\u4e2d\u65ad\u4f11\u7720\u65f6\u95f4\u3002<\/p>\n<p>\u672c\u7bc7\u5173\u4e8e\u300aPython \u4f11\u7720\u671f\u95f4\u5982\u4f55\u6267\u884c\u5176\u4ed6\u64cd\u4f5c\uff1f\u300b\u7684\u4ecb\u7ecd\u5c31\u5230\u6b64\u7ed3\u675f\u5566\uff0c\u4f46\u662f\u5b66\u65e0\u6b62\u5883\uff0c\u60f3\u8981\u4e86\u89e3\u5b66\u4e60\u66f4\u591a\u5173\u4e8e\u6587\u7ae0\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u8bf7\u5173\u6ce8\u516c\u4f17\u53f7\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python \u4f11\u7720\u671f\u95f4\u5982\u4f55\u6267\u884c\u5176&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-204118","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204118","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=204118"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204118\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=204118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=204118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=204118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}