{"id":834,"date":"2024-11-07T08:39:10","date_gmt":"2024-11-07T00:39:10","guid":{"rendered":"https:\/\/fwq.ai\/blog\/834\/"},"modified":"2024-11-07T08:39:10","modified_gmt":"2024-11-07T00:39:10","slug":"%e5%a6%82%e4%bd%95%e6%b5%8b%e9%87%8f-python-%e7%a8%8b%e5%ba%8f%e7%9a%84%e6%89%a7%e8%a1%8c%e6%97%b6%e9%97%b4%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/834\/","title":{"rendered":"\u5982\u4f55\u6d4b\u91cf Python \u7a0b\u5e8f\u7684\u6267\u884c\u65f6\u95f4\uff1f"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1144\" src=\"https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/172995038963854.jpg\" width=\"800\" height=\"320\" srcset=\"https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/172995038963854.jpg 800w, https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/172995038963854-300x120.jpg 300w, https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/172995038963854-768x307.jpg 768w, https:\/\/fwq.ai\/blog\/wp-content\/uploads\/2024\/11\/172995038963854-670x268.jpg 670w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" title=\"\u5982\u4f55\u6d4b\u91cf Python \u7a0b\u5e8f\u7684\u6267\u884c\u65f6\u95f4\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u6d4b\u91cf Python \u7a0b\u5e8f\u7684\u6267\u884c\u65f6\u95f4\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u6d4b\u91cf python \u7a0b\u5e8f\u6267\u884c\u65f6\u95f4<\/strong><\/p>\n<p>\u4f60\u60f3\u83b7\u6089\u7a0b\u5e8f\u6267\u884c\u8017\u65f6\uff1fpython \u4e2d\uff0c\u6700\u4fbf\u6377\u7684\u65b9\u6cd5\u662f\uff1a<\/p>\n<pre>import time\nstart_time = time.time()\nmain()  # \u4f60\u7684\u7a0b\u5e8f\u5165\u53e3\nprint(\"--- %.8f seconds ---\" % (time.time() - start_time))<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u786e\u4fdd\u7a0b\u5e8f\u8fd0\u884c\u65f6\u957f\u81f3\u5c11\u5341\u5206\u4e4b\u4e00\u79d2\u4ee5\u4e0a\u3002\u6253\u5370\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<pre>--- 0.76489186 seconds ---<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5c0f\u63d0\u793a\uff1a\u5176\u4ed6\u8ba1\u65f6\u65b9\u6cd5\uff0c\u5982 timeit \u6a21\u5757\uff0c\u66f4\u9002\u5408\u5fae\u5c0f\u4ee3\u7801\u6bb5\u7684\u8ba1\u65f6\uff0c\u800c\u4e0a\u8ff0\u65b9\u6cd5\u9002\u7528\u4e8e\u6d4b\u91cf\u6574\u4e2a\u7a0b\u5e8f\u7684\u6267\u884c\u65f6\u95f4\u3002<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201cPython\u514d\u8d39\u5b66\u4e60\u7b14\u8bb0\uff08\u6df1\u5165\uff09\u201d\uff1b<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u6d4b\u91cf Python \u7a0b\u5e8f\u7684\u6267\u884c\u65f6\u95f4\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6d4b\u91cf python \u7a0b\u5e8f\u6267\u884c\u65f6\u95f4 \u4f60\u60f3\u83b7\u6089\u7a0b\u5e8f\u6267\u884c\u8017\u65f6\uff1fpython \u4e2d\uff0c\u6700\u4fbf\u6377\u7684\u65b9\u6cd5\u662f\uff1a import time start_time = time.time() main() # \u4f60\u7684\u7a0b\u5e8f\u5165\u53e3 print(&#8220;&#8212; %.8f seconds &#8212;&#8221; % (time.time() &#8211; start_time)) \u767b\u5f55\u540e\u590d\u5236 \u786e\u4fdd\u7a0b\u5e8f\u8fd0\u884c\u65f6\u957f\u81f3\u5c11\u5341\u5206\u4e4b\u4e00\u79d2\u4ee5\u4e0a\u3002\u6253\u5370\u7ed3\u679c\u5982\u4e0b\uff1a &#8212; 0.76489186 seconds &#8212; \u767b\u5f55\u540e\u590d\u5236 \u5c0f\u63d0\u793a\uff1a\u5176\u4ed6\u8ba1\u65f6\u65b9\u6cd5\uff0c\u5982 timeit \u6a21\u5757\uff0c\u66f4\u9002\u5408\u5fae\u5c0f\u4ee3\u7801\u6bb5\u7684\u8ba1\u65f6\uff0c\u800c\u4e0a\u8ff0\u65b9\u6cd5\u9002\u7528\u4e8e\u6d4b\u91cf\u6574\u4e2a\u7a0b\u5e8f\u7684\u6267\u884c\u65f6\u95f4\u3002 \u7acb\u5373\u5b66\u4e60\u201cPython\u514d\u8d39\u5b66\u4e60\u7b14\u8bb0\uff08\u6df1\u5165\uff09\u201d\uff1b \u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u6d4b\u91cf Python \u7a0b\u5e8f\u7684\u6267\u884c\u65f6\u95f4\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/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-834","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/834","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=834"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/834\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=834"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=834"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=834"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}