{"id":1029226,"date":"2024-12-31T11:06:21","date_gmt":"2024-12-31T03:06:21","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1029226.html"},"modified":"2024-12-31T11:06:24","modified_gmt":"2024-12-31T03:06:24","slug":"python%e5%88%b6%e4%bd%9c%e7%9a%84%e6%b8%b8%e6%88%8f%e5%a6%82%e4%bd%95%e8%bd%ac%e5%8c%96%e4%b8%baswf","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1029226.html","title":{"rendered":"python\u5236\u4f5c\u7684\u6e38\u620f\u5982\u4f55\u8f6c\u5316\u4e3aSWF"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/12\/13e63b5a-c49c-4c7a-9b33-9e7f8deff66d.webp?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"python\u5236\u4f5c\u7684\u6e38\u620f\u5982\u4f55\u8f6c\u5316\u4e3aSWF\" \/><\/p>\n<p><p> <strong>\u5c06Python\u5236\u4f5c\u7684\u6e38\u620f\u8f6c\u5316\u4e3aSWF<\/strong>\u9700\u8981\u4f7f\u7528\u4e00\u4e9b\u7279\u5b9a\u5de5\u5177\u548c\u65b9\u6cd5\u3002\u4ee5\u4e0b\u662f\u6838\u5fc3\u89c2\u70b9\uff1a<strong>\u4f7f\u7528Py2Exe\u5c06Python\u4ee3\u7801\u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6\u3001\u5229\u7528\u7b2c\u4e09\u65b9\u5de5\u5177\u5c06\u53ef\u6267\u884c\u6587\u4ef6\u8f6c\u6362\u4e3aSWF\u3001\u4f7f\u7528\u7b2c\u4e09\u65b9\u5e93\u5982Pygame\u5236\u4f5c\u6e38\u620f<\/strong>\u3002\u5176\u4e2d\uff0c<strong>\u4f7f\u7528\u7b2c\u4e09\u65b9\u5e93\u5982Pygame\u5236\u4f5c\u6e38\u620f<\/strong>\u662f\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u6b65\u9aa4\uff0c\u56e0\u4e3a\u5b83\u63d0\u4f9b\u4e86\u8bb8\u591a\u6709\u7528\u7684\u529f\u80fd\u6765\u521b\u5efa\u6e38\u620f\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4f7f\u7528Py2Exe\u5c06Python\u4ee3\u7801\u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6<\/h3>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u9700\u8981\u5c06Python\u4ee3\u7801\u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6\u3002Py2Exe\u662f\u4e00\u4e2a\u5c06Python\u811a\u672c\u8f6c\u6362\u4e3aWindows\u53ef\u6267\u884c\u7a0b\u5e8f\u7684\u5de5\u5177\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528Py2Exe\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u5b89\u88c5Py2Exe\uff1a\u901a\u8fc7pip\u5b89\u88c5Py2Exe\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">pip install py2exe<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li>\u521b\u5efa\u4e00\u4e2asetup\u811a\u672c\uff1a\u5728\u4f60\u7684\u9879\u76ee\u76ee\u5f55\u4e2d\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>setup.py<\/code>\u7684\u6587\u4ef6\uff0c\u7528\u6765\u914d\u7f6e\u5982\u4f55\u6253\u5305\u4f60\u7684Python\u811a\u672c\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">from distutils.core import setup<\/p>\n<p>import py2exe<\/p>\n<p>setup(console=[&#39;your_script.py&#39;])<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li>\u8fd0\u884csetup\u811a\u672c\uff1a\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u5c06\u4f60\u7684Python\u811a\u672c\u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">python setup.py py2exe<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5b8c\u6210\u4ee5\u4e0a\u6b65\u9aa4\u540e\uff0c\u4f60\u4f1a\u5728\u9879\u76ee\u76ee\u5f55\u4e2d\u5f97\u5230\u4e00\u4e2a\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u5229\u7528\u7b2c\u4e09\u65b9\u5de5\u5177\u5c06\u53ef\u6267\u884c\u6587\u4ef6\u8f6c\u6362\u4e3aSWF<\/h3>\n<\/p>\n<p><p>SWF\uff08Small Web Format\uff09\u662f\u7531Adobe Flash\u521b\u5efa\u7684\u6587\u4ef6\u683c\u5f0f\uff0c\u7528\u4e8e\u591a\u5a92\u4f53\u3001\u77e2\u91cf\u56fe\u5f62\u548cActionScript\u3002\u8981\u5c06\u53ef\u6267\u884c\u6587\u4ef6\u8f6c\u6362\u4e3aSWF\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e9b\u7b2c\u4e09\u65b9\u5de5\u5177\uff0c\u4f8b\u5982Swiff Point Player\u6216\u5176\u4ed6\u7c7b\u4f3c\u5de5\u5177\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>Swiff Point Player<\/strong>\uff1a\u8fd9\u662f\u4e00\u6b3e\u53ef\u4ee5\u5c06EXE\u6587\u4ef6\u8f6c\u6362\u4e3aSWF\u6587\u4ef6\u7684\u5de5\u5177\u3002\u5177\u4f53\u4f7f\u7528\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u4e0b\u8f7d\u5e76\u5b89\u88c5Swiff Point Player\u3002<\/li>\n<li>\u6253\u5f00Swiff Point Player\uff0c\u9009\u62e9\u4f60\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/li>\n<li>\u5c06\u6587\u4ef6\u8f6c\u6362\u4e3aSWF\u683c\u5f0f\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5176\u4ed6\u5de5\u5177<\/strong>\uff1a\u5e02\u573a\u4e0a\u8fd8\u6709\u5176\u4ed6\u7c7b\u4f3c\u7684\u5de5\u5177\u53ef\u4ee5\u5b9e\u73b0\u540c\u6837\u7684\u529f\u80fd\u3002\u6839\u636e\u9700\u8981\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e09\u3001\u4f7f\u7528\u7b2c\u4e09\u65b9\u5e93\u5982Pygame\u5236\u4f5c\u6e38\u620f<\/h3>\n<\/p>\n<p><p>\u5728\u5c06\u6e38\u620f\u8f6c\u6362\u4e3aSWF\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u4f7f\u7528Python\u521b\u5efa\u6e38\u620f\u3002Pygame\u662f\u4e00\u4e2a\u6d41\u884c\u7684Python\u5e93\uff0c\u7528\u4e8e\u5f00\u53d12D\u6e38\u620f\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684Pygame\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u5b89\u88c5Pygame\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">pip install pygame<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li>\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684Pygame\u811a\u672c\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">import pygame<\/p>\n<p>import sys<\/p>\n<p>from pygame.locals import *<\/p>\n<h2><strong>\u521d\u59cb\u5316Pygame<\/strong><\/h2>\n<p>pygame.init()<\/p>\n<h2><strong>\u8bbe\u7f6e\u5c4f\u5e55\u5c3a\u5bf8<\/strong><\/h2>\n<p>screen = pygame.display.set_mode((400, 300))<\/p>\n<h2><strong>\u8bbe\u7f6e\u7a97\u53e3\u6807\u9898<\/strong><\/h2>\n<p>pygame.display.set_caption(&#39;Simple Pygame Example&#39;)<\/p>\n<h2><strong>\u4e3b\u6e38\u620f\u5faa\u73af<\/strong><\/h2>\n<p>while True:<\/p>\n<p>    for event in pygame.event.get():<\/p>\n<p>        if event.type == QUIT:<\/p>\n<p>            pygame.quit()<\/p>\n<p>            sys.exit()<\/p>\n<p>    # \u586b\u5145\u5c4f\u5e55\u989c\u8272<\/p>\n<p>    screen.fill((255, 255, 255))<\/p>\n<p>    # \u66f4\u65b0\u5c4f\u5e55<\/p>\n<p>    pygame.display.update()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li>\u8fd0\u884c\u4f60\u7684Pygame\u811a\u672c\uff0c\u786e\u4fdd\u6e38\u620f\u53ef\u4ee5\u6b63\u5e38\u8fd0\u884c\u3002<\/li>\n<\/ol>\n<p><h3>\u56db\u3001\u6ce8\u610f\u4e8b\u9879\u548c\u6700\u4f73\u5b9e\u8df5<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u517c\u5bb9\u6027\u95ee\u9898<\/strong>\uff1a\u8f6c\u6362\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u4f1a\u9047\u5230\u517c\u5bb9\u6027\u95ee\u9898\uff0c\u4f8b\u5982\u6587\u4ef6\u5927\u5c0f\u3001\u6027\u80fd\u7b49\u3002\u786e\u4fdd\u4f60\u7684\u6e38\u620f\u5728\u8f6c\u6362\u540e\u80fd\u591f\u6b63\u5e38\u8fd0\u884c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f18\u5316\u6e38\u620f\u6027\u80fd<\/strong>\uff1a\u5728\u5236\u4f5c\u6e38\u620f\u65f6\uff0c\u6ce8\u610f\u4f18\u5316\u6e38\u620f\u6027\u80fd\u3002\u4f8b\u5982\uff0c\u51cf\u5c11\u56fe\u50cf\u8d44\u6e90\u7684\u5927\u5c0f\uff0c\u4f18\u5316\u4ee3\u7801\u903b\u8f91\u7b49\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6d4b\u8bd5\u548c\u8c03\u8bd5<\/strong>\uff1a\u5728\u8f6c\u6362\u4e3aSWF\u6587\u4ef6\u540e\uff0c\u52a1\u5fc5\u8fdb\u884c\u5145\u5206\u7684\u6d4b\u8bd5\u548c\u8c03\u8bd5\uff0c\u786e\u4fdd\u6e38\u620f\u5728\u5404\u79cd\u73af\u5883\u4e2d\u90fd\u80fd\u6b63\u5e38\u8fd0\u884c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b66\u4e60ActionScript<\/strong>\uff1a\u5982\u679c\u4f60\u5bf9Flash\u548cActionScript\u6709\u4e00\u5b9a\u4e86\u89e3\uff0c\u53ef\u4ee5\u66f4\u597d\u5730\u63a7\u5236\u548c\u4f18\u5316\u4f60\u7684SWF\u6587\u4ef6\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5de5\u5177\u66f4\u65b0\u548c\u652f\u6301<\/strong>\uff1a\u968f\u7740\u6280\u672f\u7684\u53d1\u5c55\uff0c\u5de5\u5177\u548c\u5e93\u53ef\u80fd\u4f1a\u66f4\u65b0\u3002\u4fdd\u6301\u5bf9\u6700\u65b0\u6280\u672f\u548c\u5de5\u5177\u7684\u5173\u6ce8\uff0c\u786e\u4fdd\u4f60\u7684\u8f6c\u6362\u6d41\u7a0b\u662f\u6700\u65b0\u548c\u6700\u6709\u6548\u7684\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e94\u3001\u603b\u7ed3<\/h3>\n<\/p>\n<p><p>\u5c06Python\u5236\u4f5c\u7684\u6e38\u620f\u8f6c\u6362\u4e3aSWF\u6587\u4ef6\u9700\u8981\u7ecf\u8fc7\u51e0\u4e2a\u6b65\u9aa4\uff1a\u9996\u5148\u4f7f\u7528Py2Exe\u5c06Python\u4ee3\u7801\u6253\u5305\u6210\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u7136\u540e\u5229\u7528\u7b2c\u4e09\u65b9\u5de5\u5177\u5c06\u53ef\u6267\u884c\u6587\u4ef6\u8f6c\u6362\u4e3aSWF\u6587\u4ef6\u3002\u5728\u6574\u4e2a\u8fc7\u7a0b\u4e2d\uff0c\u4f7f\u7528Pygame\u7b49\u7b2c\u4e09\u65b9\u5e93\u5236\u4f5c\u6e38\u620f\u662f\u975e\u5e38\u91cd\u8981\u7684\uff0c\u56e0\u4e3a\u5b83\u63d0\u4f9b\u4e86\u8bb8\u591a\u6709\u7528\u7684\u529f\u80fd\u6765\u521b\u5efa\u6e38\u620f\u3002\u6700\u540e\uff0c\u6ce8\u610f\u517c\u5bb9\u6027\u95ee\u9898\u3001\u4f18\u5316\u6e38\u620f\u6027\u80fd\u3001\u6d4b\u8bd5\u548c\u8c03\u8bd5\uff0c\u4ee5\u53ca\u5b66\u4e60\u76f8\u5173\u6280\u672f\uff0c\u4ee5\u786e\u4fdd\u8f6c\u6362\u540e\u7684\u6e38\u620f\u80fd\u591f\u6b63\u5e38\u8fd0\u884c\u5e76\u83b7\u5f97\u6700\u4f73\u6027\u80fd\u3002\u901a\u8fc7\u8fd9\u4e9b\u6b65\u9aa4\uff0c\u4f60\u53ef\u4ee5\u6210\u529f\u5730\u5c06Python\u5236\u4f5c\u7684\u6e38\u620f\u8f6c\u6362\u4e3aSWF\u6587\u4ef6\uff0c\u5e76\u5728\u4e0d\u540c\u7684\u5e73\u53f0\u4e0a\u53d1\u5e03\u548c\u5206\u4eab\u4f60\u7684\u6e38\u620f\u4f5c\u54c1\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5c06Python\u6e38\u620f\u8f6c\u6362\u4e3aSWF\u683c\u5f0f\uff1f<\/strong><br \/>\u5c06Python\u6e38\u620f\u8f6c\u6362\u4e3aSWF\u683c\u5f0f\u5e76\u4e0d\u662f\u4e00\u4e2a\u76f4\u63a5\u7684\u8fc7\u7a0b\uff0c\u56e0\u4e3aSWF\u4e3b\u8981\u662f\u7528\u4e8eAdobe Flash\u7684\u683c\u5f0f\uff0c\u800cPython\u901a\u5e38\u7528\u4e8e\u5f00\u53d1\u684c\u9762\u6216\u7f51\u7edc\u6e38\u620f\u3002\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u4e00\u4e9b\u5de5\u5177\u6216\u5e93\uff0c\u6bd4\u5982Pyjs\uff08\u4ee5\u524d\u79f0\u4e3aPyjamas\uff09\uff0c\u5b83\u53ef\u4ee5\u5c06Python\u4ee3\u7801\u8f6c\u6362\u4e3aJavaScript\uff0c\u4ece\u800c\u4f7f\u6e38\u620f\u80fd\u591f\u5728\u7f51\u9875\u4e0a\u8fd0\u884c\u3002\u7136\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u5de5\u5177\u5c06JavaScript\u4ee3\u7801\u8f6c\u6362\u4e3aSWF\u6587\u4ef6\u3002\u7136\u800c\uff0c\u8fd9\u4e2a\u8fc7\u7a0b\u53ef\u80fd\u9700\u8981\u4e00\u4e9b\u989d\u5916\u7684\u5b66\u4e60\u548c\u8c03\u6574\u3002<\/p>\n<p><strong>\u4f7f\u7528SWF\u683c\u5f0f\u7684\u6e38\u620f\u6709\u4ec0\u4e48\u4f18\u52bf\uff1f<\/strong><br \/>SWF\u683c\u5f0f\u7684\u6e38\u620f\u901a\u5e38\u53ef\u4ee5\u5728\u591a\u79cd\u5e73\u53f0\u4e0a\u8fd0\u884c\uff0c\u5305\u62ec\u7f51\u9875\u6d4f\u89c8\u5668\uff0c\u8fd9\u4f7f\u5f97\u5b83\u4eec\u5728\u7528\u6237\u4e2d\u66f4\u6613\u4e8e\u4f20\u64ad\u548c\u5206\u4eab\u3002\u540c\u65f6\uff0c\u7531\u4e8eSWF\u6587\u4ef6\u901a\u5e38\u8f83\u5c0f\uff0c\u53ef\u4ee5\u5feb\u901f\u52a0\u8f7d\uff0c\u56e0\u6b64\u63d0\u4f9b\u4e86\u66f4\u597d\u7684\u7528\u6237\u4f53\u9a8c\u3002\u6b64\u5916\uff0cSWF\u652f\u6301\u77e2\u91cf\u56fe\u5f62\u548c\u52a8\u753b\uff0c\u4f7f\u5f97\u6e38\u620f\u7684\u89c6\u89c9\u6548\u679c\u66f4\u52a0\u751f\u52a8\u3002<\/p>\n<p><strong>Python\u6e38\u620f\u8f6c\u6362\u4e3aSWF\u540e\u662f\u5426\u9700\u8981\u8003\u8651\u517c\u5bb9\u6027\u95ee\u9898\uff1f<\/strong><br \/>\u662f\u7684\uff0c\u8f6c\u6362\u540e\u7684SWF\u6587\u4ef6\u53ef\u80fd\u4f1a\u9762\u4e34\u517c\u5bb9\u6027\u95ee\u9898\uff0c\u7279\u522b\u662f\u5728\u4e0d\u540c\u7684\u6d4f\u89c8\u5668\u548c\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u3002\u7531\u4e8eFlash Player\u7684\u652f\u6301\u9010\u6e10\u51cf\u5c11\uff0c\u8bb8\u591a\u73b0\u4ee3\u6d4f\u89c8\u5668\u5df2\u7ecf\u505c\u6b62\u652f\u6301SWF\u683c\u5f0f\u3002\u56e0\u6b64\uff0c\u5728\u51b3\u5b9a\u5c06Python\u6e38\u620f\u8f6c\u6362\u4e3aSWF\u4e4b\u524d\uff0c\u5efa\u8bae\u8003\u8651\u4f7f\u7528\u66f4\u73b0\u4ee3\u7684\u6280\u672f\uff0c\u5982HTML5\u548cJavaScript\uff0c\u8fd9\u4e9b\u6280\u672f\u5728\u5f53\u524d\u7684\u7f51\u7edc\u73af\u5883\u4e2d\u66f4\u5177\u517c\u5bb9\u6027\u548c\u53ef\u8bbf\u95ee\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5c06Python\u5236\u4f5c\u7684\u6e38\u620f\u8f6c\u5316\u4e3aSWF\u9700\u8981\u4f7f\u7528\u4e00\u4e9b\u7279\u5b9a\u5de5\u5177\u548c\u65b9\u6cd5\u3002\u4ee5\u4e0b\u662f\u6838\u5fc3\u89c2\u70b9\uff1a\u4f7f\u7528Py2Exe\u5c06Python [&hellip;]","protected":false},"author":3,"featured_media":1029235,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1029226"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1029226"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1029226\/revisions"}],"predecessor-version":[{"id":1029237,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1029226\/revisions\/1029237"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1029235"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1029226"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1029226"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1029226"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}