{"id":52786,"date":"2024-12-03T08:05:23","date_gmt":"2024-12-03T00:05:23","guid":{"rendered":"https:\/\/fwq.ai\/blog\/52786\/"},"modified":"2024-12-03T08:05:23","modified_gmt":"2024-12-03T00:05:23","slug":"python%e9%97%ad%e5%8c%85%e8%bf%b7%e6%80%9d%ef%bc%9a%e4%b8%ba%e4%bb%80%e4%b9%88%e4%b8%80%e7%a7%8d%e5%86%99%e6%b3%95%e6%97%a0%e6%b3%95%e8%be%93%e5%87%ba%ef%bc%8c%e5%8f%a6%e4%b8%80%e7%a7%8d%e5%8d%b4","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/52786\/","title":{"rendered":"Python\u95ed\u5305\u8ff7\u601d\uff1a\u4e3a\u4ec0\u4e48\u4e00\u79cd\u5199\u6cd5\u65e0\u6cd5\u8f93\u51fa\uff0c\u53e6\u4e00\u79cd\u5374\u80fd\u6253\u5370FPS\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>Python\u95ed\u5305\u8ff7\u601d\uff1a\u4e3a\u4ec0\u4e48\u4e00\u79cd\u5199\u6cd5\u65e0\u6cd5\u8f93\u51fa\uff0c\u53e6\u4e00\u79cd\u5374\u80fd\u6253\u5370FPS\uff1f<\/h1>\n<p>\u7c73\u4e91\u4eca\u5929\u5c06\u7ed9\u5927\u5bb6\u5e26\u6765<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300aPython\u95ed\u5305\u8ff7\u601d\uff1a\u4e3a\u4ec0\u4e48\u4e00\u79cd\u5199\u6cd5\u65e0\u6cd5\u8f93\u51fa\uff0c\u53e6\u4e00\u79cd\u5374\u80fd\u6253\u5370FPS\uff1f\u300b<\/span>\uff0c\u611f\u5174\u8da3\u7684\u670b\u53cb\u8bf7\u7ee7\u7eed\u770b\u4e0b\u53bb\u5427\uff01\u4ee5\u4e0b\u5185\u5bb9\u5c06\u4f1a\u6d89\u53ca\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u5982\u679c\u4f60\u662f\u6b63\u5728\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u6216\u8005\u5df2\u7ecf\u662f\u5927\u4f6c\u7ea7\u522b\u4e86\uff0c\u90fd\u975e\u5e38\u6b22\u8fce\u4e5f\u5e0c\u671b\u5927\u5bb6\u90fd\u80fd\u7ed9\u6211\u5efa\u8bae\u8bc4\u8bba\u54c8~\u5e0c\u671b\u80fd\u5e2e\u52a9\u5230\u5927\u5bb6\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241123\/173234469767417b79a3152.jpg\" class=\"aligncenter\" title=\"Python\u95ed\u5305\u8ff7\u601d\uff1a\u4e3a\u4ec0\u4e48\u4e00\u79cd\u5199\u6cd5\u65e0\u6cd5\u8f93\u51fa\uff0c\u53e6\u4e00\u79cd\u5374\u80fd\u6253\u5370FPS\uff1f\u63d2\u56fe\" alt=\"Python\u95ed\u5305\u8ff7\u601d\uff1a\u4e3a\u4ec0\u4e48\u4e00\u79cd\u5199\u6cd5\u65e0\u6cd5\u8f93\u51fa\uff0c\u53e6\u4e00\u79cd\u5374\u80fd\u6253\u5370FPS\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>python \u95ed\u5305\u8f93\u51fa\u8c1c\u9898<\/strong><\/p>\n<p>\u5728 python \u4e2d\uff0c\u95ed\u5305\u662f\u6307\u53ef\u4ee5\u8bbf\u95ee\u5176\u5d4c\u5957\u51fd\u6570\u4e2d\u5c40\u90e8\u53d8\u91cf\u7684\u51fd\u6570\u3002\u7136\u800c\uff0c\u6709\u65f6\u95ed\u5305\u7684\u884c\u4e3a\u53ef\u80fd\u4ee4\u4eba\u8d39\u89e3\uff0c\u5bfc\u81f4\u65e0\u6cd5\u8f93\u51fa\u9884\u671f\u7ed3\u679c\u3002<\/p>\n<p><strong>\u95ee\u9898<\/strong><\/p>\n<p>\u4ee5\u4e0b\u4ee3\u7801\u7247\u6bb5\u4e2d\uff0c\u4e3a\u4f55\u7b2c\u4e00\u79cd\u5199\u6cd5\u65e0\u6cd5\u8f93\u51fa\u4efb\u4f55\u5185\u5bb9\uff0c\u800c\u7b2c\u4e8c\u79cd\u53ef\u4ee5\u8f93\u51fa\u5462\uff1f<\/p>\n<pre># \u7b2c\u4e00\u5199\u6cd5\ndef startgame(fps):\n    def update():\n        print('FPS: ', fps)\n    return update  # \u8fd4\u56de\u51fd\u6570\n\n# \u8c03\u7528#1\nupdate = startgame(60)\n\n# \u7b2c\u4e8c\u5199\u6cd5\ndef startgame(fps):\n    def update():\n        print('FPS: ', fps)\n    return update()  # \u8fd4\u56de\u8c03\u7528\u540e\u7684\u51fd\u6570\n\n# \u8c03\u7528#2\nupdate = startgame(60)\nupdate()\n<\/pre>\n<p><strong>\u7b54\u6848<\/strong><\/p>\n<p>\u8fd9\u5e76\u4e0d\u662f\u95ed\u5305\u95ee\u9898\uff0c\u800c\u662f\u51fd\u6570\u8c03\u7528\u7684\u8bef\u89e3\u3002<\/p>\n<p><strong>\u7b2c\u4e00\u79cd\u5199\u6cd5<\/strong><\/p>\n<p>\u5728\u7b2c\u4e00\u79cd\u5199\u6cd5\u4e2d\uff0cstartgame \u8fd4\u56de\u4e00\u4e2a\u51fd\u6570 update\uff0c\u4f46\u662f\u5e76\u6ca1\u6709\u8c03\u7528\u5b83\u3002\u56e0\u6b64\uff0c\u4e5f\u6ca1\u6709\u8f93\u51fa\u3002<\/p>\n<p><strong>\u7b2c\u4e8c\u79cd\u5199\u6cd5<\/strong><\/p>\n<p>\u5728\u7b2c\u4e8c\u79cd\u5199\u6cd5\u4e2d\uff0cstartgame \u8fd4\u56de\u7684\u662f\u8c03\u7528\u540e\u7684\u51fd\u6570 update\uff0c\u5b83\u7acb\u5373\u88ab\u8c03\u7528\u4e86\u3002\u56e0\u6b64\uff0c\u4f1a\u8f93\u51fa fps: 60\u3002<\/p>\n<p><strong>\u7ed3\u8bba<\/strong><\/p>\n<p>\u56e0\u6b64\uff0c\u5f53\u9700\u8981\u8c03\u7528\u51fd\u6570\u65f6\uff0c\u786e\u4fdd\u4e0d\u8fd4\u56de\u51fd\u6570\u672c\u8eab\uff0c\u800c\u662f\u8fd4\u56de\u5176\u8c03\u7528\u540e\u7684\u7ed3\u679c\uff0c\u8fd9\u6837\u624d\u80fd\u83b7\u5f97\u9884\u671f\u8f93\u51fa\u3002<\/p>\n<p>\u7ec8\u4e8e\u4ecb\u7ecd\u5b8c\u5566\uff01\u5c0f\u4f19\u4f34\u4eec\uff0c\u8fd9\u7bc7\u5173\u4e8e\u300aPython\u95ed\u5305\u8ff7\u601d\uff1a\u4e3a\u4ec0\u4e48\u4e00\u79cd\u5199\u6cd5\u65e0\u6cd5\u8f93\u51fa\uff0c\u53e6\u4e00\u79cd\u5374\u80fd\u6253\u5370FPS\uff1f\u300b\u7684\u4ecb\u7ecd\u5e94\u8be5\u8ba9\u4f60\u6536\u83b7\u591a\u591a\u4e86\u5427\uff01\u6b22\u8fce\u5927\u5bb6\u6536\u85cf\u6216\u5206\u4eab\u7ed9\u66f4\u591a\u9700\u8981\u5b66\u4e60\u7684\u670b\u53cb\u5427~\u7c73\u4e91\u516c\u4f17\u53f7\u4e5f\u4f1a\u53d1\u5e03\u6587\u7ae0\u76f8\u5173\u77e5\u8bc6\uff0c\u5feb\u6765\u5173\u6ce8\u5427\uff01<\/p>\n<dl>\n<dt><\/dt>\n<dd>\n   windows\u5b89\u5168\u4e2d\u5fc3\u6253\u5f00\u767d\u5c4f\u600e\u4e48\u56de\u4e8b\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>Python\u95ed\u5305\u8ff7\u601d\uff1a\u4e3a\u4ec0\u4e48\u4e00\u79cd\u5199\u6cd5\u65e0\u6cd5\u8f93\u51fa\uff0c\u53e6\u4e00\u79cd\u5374\u80fd\u6253\u5370FPS\uff1f \u7c73\u4e91\u4eca\u5929\u5c06\u7ed9\u5927\u5bb6\u5e26\u6765\u300aPython\u95ed\u5305\u8ff7\u601d\uff1a\u4e3a\u4ec0\u4e48\u4e00\u79cd\u5199\u6cd5\u65e0\u6cd5\u8f93\u51fa\uff0c\u53e6\u4e00\u79cd\u5374\u80fd\u6253\u5370FPS\uff1f\u300b\uff0c\u611f\u5174\u8da3\u7684\u670b\u53cb\u8bf7\u7ee7\u7eed\u770b\u4e0b\u53bb\u5427\uff01\u4ee5\u4e0b\u5185\u5bb9\u5c06\u4f1a\u6d89\u53ca\u5230\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u5982\u679c\u4f60\u662f\u6b63\u5728\u5b66\u4e60\u6587\u7ae0\u6216\u8005\u5df2\u7ecf\u662f\u5927\u4f6c\u7ea7\u522b\u4e86\uff0c\u90fd\u975e\u5e38\u6b22\u8fce\u4e5f\u5e0c\u671b\u5927\u5bb6\u90fd\u80fd\u7ed9\u6211\u5efa\u8bae\u8bc4\u8bba\u54c8~\u5e0c\u671b\u80fd\u5e2e\u52a9\u5230\u5927\u5bb6\uff01 python \u95ed\u5305\u8f93\u51fa\u8c1c\u9898 \u5728 python \u4e2d\uff0c\u95ed\u5305\u662f\u6307\u53ef\u4ee5\u8bbf\u95ee\u5176\u5d4c\u5957\u51fd\u6570\u4e2d\u5c40\u90e8\u53d8\u91cf\u7684\u51fd\u6570\u3002\u7136\u800c\uff0c\u6709\u65f6\u95ed\u5305\u7684\u884c\u4e3a\u53ef\u80fd\u4ee4\u4eba\u8d39\u89e3\uff0c\u5bfc\u81f4\u65e0\u6cd5\u8f93\u51fa\u9884\u671f\u7ed3\u679c\u3002 \u95ee\u9898 \u4ee5\u4e0b\u4ee3\u7801\u7247\u6bb5\u4e2d\uff0c\u4e3a\u4f55\u7b2c\u4e00\u79cd\u5199\u6cd5\u65e0\u6cd5\u8f93\u51fa\u4efb\u4f55\u5185\u5bb9\uff0c\u800c\u7b2c\u4e8c\u79cd\u53ef\u4ee5\u8f93\u51fa\u5462\uff1f # \u7b2c\u4e00\u5199\u6cd5 def startgame(fps): def update(): print(&#8216;FPS: &#8216;, fps) return update # \u8fd4\u56de\u51fd\u6570 # \u8c03\u7528#1 update = startgame(60) # \u7b2c\u4e8c\u5199\u6cd5 def startgame(fps): def update(): print(&#8216;FPS: &#8216;, fps) return update() # \u8fd4\u56de\u8c03\u7528\u540e\u7684\u51fd\u6570 # \u8c03\u7528#2 update = startgame(60) update() \u7b54\u6848 \u8fd9\u5e76\u4e0d\u662f\u95ed\u5305\u95ee\u9898\uff0c\u800c\u662f\u51fd\u6570\u8c03\u7528\u7684\u8bef\u89e3\u3002 \u7b2c\u4e00\u79cd\u5199\u6cd5 \u5728\u7b2c\u4e00\u79cd\u5199\u6cd5\u4e2d\uff0cstartgame \u8fd4\u56de\u4e00\u4e2a\u51fd\u6570 update\uff0c\u4f46\u662f\u5e76\u6ca1\u6709\u8c03\u7528\u5b83\u3002\u56e0\u6b64\uff0c\u4e5f\u6ca1\u6709\u8f93\u51fa\u3002 \u7b2c\u4e8c\u79cd\u5199\u6cd5 \u5728\u7b2c\u4e8c\u79cd\u5199\u6cd5\u4e2d\uff0cstartgame \u8fd4\u56de\u7684\u662f\u8c03\u7528\u540e\u7684\u51fd\u6570 [&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-52786","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52786","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=52786"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52786\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=52786"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=52786"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=52786"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}