{"id":990171,"date":"2024-12-27T08:17:56","date_gmt":"2024-12-27T00:17:56","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/990171.html"},"modified":"2024-12-27T08:17:59","modified_gmt":"2024-12-27T00:17:59","slug":"%e5%a6%82%e4%bd%95%e6%89%93%e5%bc%80python%e5%b0%8f%e6%b8%b8%e6%88%8f","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/990171.html","title":{"rendered":"\u5982\u4f55\u6253\u5f00python\u5c0f\u6e38\u620f"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25065026\/fd0b6ed4-7cd2-4b41-858d-1c3677fbd981.webp\" alt=\"\u5982\u4f55\u6253\u5f00python\u5c0f\u6e38\u620f\" \/><\/p>\n<p><p> \u6253\u5f00Python\u5c0f\u6e38\u620f\u7684\u6b65\u9aa4\u4e3b\u8981\u5305\u62ec<strong>\u4e0b\u8f7d\u6e38\u620f\u4ee3\u7801\u3001\u5b89\u88c5Python\u73af\u5883\u3001\u8fd0\u884c\u6e38\u620f\u811a\u672c<\/strong>\u3002\u5176\u4e2d\uff0c\u5b89\u88c5Python\u73af\u5883\u662f\u5173\u952e\uff0c\u56e0\u4e3a\u5b83\u4e3a\u6e38\u620f\u63d0\u4f9b\u4e86\u8fd0\u884c\u7684\u57fa\u7840\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u5c06\u8be6\u7ec6\u63cf\u8ff0\u5982\u4f55\u5b89\u88c5Python\u73af\u5883\u3002<\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u786e\u4fdd\u60a8\u5df2\u5728\u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5\u4e86Python\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u8bbf\u95eePython\u7684\u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/www.python.org\/downloads\/%EF%BC%89%E4%B8%8B%E8%BD%BD%E9%80%82%E5%90%88%E6%82%A8%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E7%9A%84%E7%89%88%E6%9C%AC%E3%80%82%E5%AE%89%E8%A3%85%E5%AE%8C%E6%88%90%E5%90%8E%EF%BC%8C%E6%82%A8%E5%8F%AF%E4%BB%A5%E5%9C%A8%E5%91%BD%E4%BB%A4%E8%A1%8C%E4%B8%AD%E8%BE%93%E5%85%A5%60python\">https:\/\/www.python.org\/downloads\/\uff09\u4e0b\u8f7d\u9002\u5408\u60a8\u64cd\u4f5c\u7cfb\u7edf\u7684\u7248\u672c\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165`python<\/a> &#8211;version`\u6765\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\u3002\u5982\u679c\u8f93\u51fa\u4e86Python\u7684\u7248\u672c\u53f7\uff0c\u5219\u8bf4\u660e\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u6253\u5f00Python\u5c0f\u6e38\u620f\u7684\u6b65\u9aa4\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u4e0b\u8f7d\u6e38\u620f\u4ee3\u7801<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u83b7\u53d6\u6e38\u620f\u4ee3\u7801<\/strong>\uff1a\u9996\u5148\uff0c\u60a8\u9700\u8981\u4ece\u4e92\u8054\u7f51\u4e0a\u4e0b\u8f7d\u60a8\u611f\u5174\u8da3\u7684Python\u5c0f\u6e38\u620f\u4ee3\u7801\u3002\u901a\u5e38\uff0c\u60a8\u53ef\u4ee5\u5728GitHub\u4e0a\u627e\u5230\u5927\u91cf\u5f00\u6e90\u7684Python\u5c0f\u6e38\u620f\u9879\u76ee\u3002\u901a\u8fc7\u641c\u7d22\u5173\u952e\u5b57\u201cPython game\u201d\u6216\u60a8\u611f\u5174\u8da3\u7684\u5177\u4f53\u6e38\u620f\u540d\u79f0\uff0c\u5373\u53ef\u627e\u5230\u76f8\u5173\u4ee3\u7801\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9009\u62e9\u5408\u9002\u7684\u7248\u672c<\/strong>\uff1a\u4e00\u4e9b\u6e38\u620f\u53ef\u80fd\u6709\u4e0d\u540c\u7684\u7248\u672c\u6216\u5206\u652f\uff0c\u8bf7\u9009\u62e9\u4e0e\u60a8\u5f53\u524dPython\u7248\u672c\u517c\u5bb9\u7684\u4ee3\u7801\u7248\u672c\u3002\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u9879\u76ee\u7684README\u6587\u4ef6\u4e2d\u4f1a\u6709\u8be6\u7ec6\u7684\u8bf4\u660e\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4e0b\u8f7d\u4ee3\u7801<\/strong>\uff1a\u4e00\u65e6\u627e\u5230\u4e86\u5408\u9002\u7684\u9879\u76ee\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528Git\u547d\u4ee4\u6216\u76f4\u63a5\u4e0b\u8f7dZIP\u6587\u4ef6\u7684\u65b9\u5f0f\u5c06\u4ee3\u7801\u4e0b\u8f7d\u5230\u672c\u5730\u8ba1\u7b97\u673a\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e8c\u3001\u5b89\u88c5Python\u73af\u5883<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5Python<\/strong>\uff1a\u5982\u524d\u6240\u8ff0\uff0c\u786e\u4fdd\u60a8\u7684\u8ba1\u7b97\u673a\u4e0a\u5df2\u7ecf\u5b89\u88c5\u4e86Python\u3002\u5982\u679c\u6ca1\u6709\uff0c\u8bf7\u8bbf\u95eePython\u5b98\u7f51\uff0c\u6839\u636e\u64cd\u4f5c\u7cfb\u7edf\u4e0b\u8f7d\u5e76\u5b89\u88c5\u9002\u5408\u7684\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5\u5fc5\u8981\u7684\u5e93<\/strong>\uff1a\u5c0f\u6e38\u620f\u901a\u5e38\u4f9d\u8d56\u4e8e\u4e00\u4e9bPython\u5e93\uff0c\u4f8b\u5982Pygame\u3001Tkinter\u7b49\u3002\u60a8\u53ef\u4ee5\u5728\u9879\u76ee\u7684README\u6587\u4ef6\u4e2d\u627e\u5230\u6240\u9700\u5e93\u7684\u6e05\u5355\u3002\u4f7f\u7528pip\u547d\u4ee4\u5b89\u88c5\u8fd9\u4e9b\u5e93\uff0c\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pygame<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u73af\u5883<\/strong>\uff1a\u4e3a\u4e86\u9a8c\u8bc1\u73af\u5883\u662f\u5426\u6b63\u786e\u914d\u7f6e\uff0c\u60a8\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684Python\u811a\u672c\u8fdb\u884c\u6d4b\u8bd5\u3002\u4f8b\u5982\uff0c\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>test.py<\/code>\u7684\u6587\u4ef6\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">print(&quot;Hello, Python!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884c<code>python test.py<\/code>\uff0c\u5982\u679c\u8f93\u51fa\u201cHello, Python!\u201d\u5219\u8bf4\u660e\u73af\u5883\u914d\u7f6e\u6b63\u786e\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e09\u3001\u8fd0\u884c\u6e38\u620f\u811a\u672c<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5bfc\u822a\u5230\u6e38\u620f\u76ee\u5f55<\/strong>\uff1a\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\uff08\u5982\u7ec8\u7aef\u6216\u547d\u4ee4\u63d0\u793a\u7b26\uff09\u5bfc\u822a\u5230\u4e0b\u8f7d\u7684\u6e38\u620f\u4ee3\u7801\u6240\u5728\u7684\u76ee\u5f55\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">cd path\/to\/game<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884c\u6e38\u620f<\/strong>\uff1a\u627e\u5230\u6e38\u620f\u7684\u4e3b\u811a\u672c\u6587\u4ef6\uff0c\u901a\u5e38\u662f\u4ee5<code>.py<\/code>\u7ed3\u5c3e\u7684\u6587\u4ef6\uff0c\u540d\u79f0\u53ef\u80fd\u4e3a<code>m<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>n.py<\/code>\u6216\u5176\u4ed6\u8bf4\u660e\u6027\u7684\u540d\u79f0\u3002\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8\u6e38\u620f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python main.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u89e3\u51b3\u53ef\u80fd\u51fa\u73b0\u7684\u95ee\u9898<\/strong>\uff1a\u5982\u679c\u5728\u8fd0\u884c\u65f6\u51fa\u73b0\u9519\u8bef\uff0c\u4ed4\u7ec6\u9605\u8bfb\u9519\u8bef\u4fe1\u606f\uff0c\u901a\u5e38\u95ee\u9898\u4e0e\u7f3a\u5c11\u7684\u5e93\u6216Python\u7248\u672c\u4e0d\u517c\u5bb9\u6709\u5173\u3002\u6839\u636e\u9519\u8bef\u63d0\u793a\uff0c\u5b89\u88c5\u7f3a\u5c11\u7684\u5e93\u6216\u8c03\u6574Python\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u56db\u3001\u5e38\u89c1\u95ee\u9898\u89e3\u51b3<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u7f3a\u5c11\u5e93<\/strong>\uff1a\u5982\u679c\u6e38\u620f\u5728\u8fd0\u884c\u65f6\u63d0\u793a\u7f3a\u5c11\u67d0\u4e2a\u5e93\uff0c\u8bf7\u4f7f\u7528pip\u5b89\u88c5\u8be5\u5e93\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install library_name<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>Python\u7248\u672c\u4e0d\u517c\u5bb9<\/strong>\uff1a\u67d0\u4e9b\u6e38\u620f\u53ef\u80fd\u8981\u6c42\u7279\u5b9a\u7684Python\u7248\u672c\u8fd0\u884c\u3002\u60a8\u53ef\u4ee5\u5728Python\u5b98\u7f51\u627e\u5230\u65e7\u7248\u672c\u7684\u5b89\u88c5\u7a0b\u5e8f\uff0c\u6216\u4f7f\u7528\u5de5\u5177\u5982pyenv\u6765\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8def\u5f84\u95ee\u9898<\/strong>\uff1a\u786e\u4fdd\u60a8\u5728\u547d\u4ee4\u884c\u4e2d\u5bfc\u822a\u5230\u6b63\u786e\u7684\u76ee\u5f55\uff0c\u5e76\u4e14\u6e38\u620f\u811a\u672c\u7684\u8def\u5f84\u6b63\u786e\u3002\u53ef\u4ee5\u4f7f\u7528<code>ls<\/code>\uff08macOS\/Linux\uff09\u6216<code>dir<\/code>\uff08Windows\uff09\u547d\u4ee4\u67e5\u770b\u5f53\u524d\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e94\u3001\u4f18\u5316\u6e38\u620f\u4f53\u9a8c<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u8c03\u6574\u6e38\u620f\u914d\u7f6e<\/strong>\uff1a\u8bb8\u591a\u6e38\u620f\u63d0\u4f9b\u4e86\u914d\u7f6e\u6587\u4ef6\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u7f16\u8f91\u8fd9\u4e9b\u6587\u4ef6\u6765\u8c03\u6574\u6e38\u620f\u7684\u8bbe\u7f6e\uff0c\u5982\u5206\u8fa8\u7387\u3001\u97f3\u91cf\u3001\u96be\u5ea6\u7b49\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4e86\u89e3\u6e38\u620f\u73a9\u6cd5<\/strong>\uff1a\u5728\u8fd0\u884c\u6e38\u620f\u4e4b\u524d\uff0c\u5efa\u8bae\u9605\u8bfb\u6e38\u620f\u7684\u8bf4\u660e\u6587\u6863\u6216README\u6587\u4ef6\uff0c\u4ee5\u4fbf\u4e86\u89e3\u6e38\u620f\u89c4\u5219\u548c\u64cd\u4f5c\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u53c2\u4e0e\u793e\u533a\u8ba8\u8bba<\/strong>\uff1a\u5982\u679c\u60a8\u5728\u6e38\u620f\u8fc7\u7a0b\u4e2d\u9047\u5230\u95ee\u9898\u6216\u5e0c\u671b\u4e86\u89e3\u66f4\u591a\u6280\u5de7\uff0c\u53c2\u4e0e\u6e38\u620f\u7684\u5f00\u53d1\u8005\u793e\u533a\u6216\u8bba\u575b\u53ef\u4ee5\u63d0\u4f9b\u5e2e\u52a9\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u60a8\u5e94\u8be5\u80fd\u591f\u6210\u529f\u6253\u5f00\u5e76\u8fd0\u884cPython\u5c0f\u6e38\u620f\u3002\u5e0c\u671b\u8fd9\u7bc7\u6307\u5357\u80fd\u5e2e\u52a9\u60a8\u66f4\u597d\u5730\u4eab\u53d7Python\u6e38\u620f\u7684\u4e50\u8da3\uff01<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728\u6211\u7684\u7535\u8111\u4e0a\u5b89\u88c5Python\u4ee5\u4fbf\u8fd0\u884c\u5c0f\u6e38\u620f\uff1f<\/strong><br \/>\u5728\u8fd0\u884cPython\u5c0f\u6e38\u620f\u4e4b\u524d\uff0c\u60a8\u9700\u8981\u786e\u4fdd\u60a8\u7684\u7535\u8111\u4e0a\u5b89\u88c5\u4e86Python\u3002\u53ef\u4ee5\u8bbf\u95eePython\u5b98\u65b9\u7f51\u7ad9\uff08python.org\uff09\uff0c\u4e0b\u8f7d\u5e76\u5b89\u88c5\u6700\u65b0\u7248\u672c\u7684Python\u3002\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u8bf7\u786e\u4fdd\u52fe\u9009\u201cAdd Python to PATH\u201d\u9009\u9879\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u8f93\u5165<code>python<\/code>\u6216<code>python3<\/code>\u6765\u68c0\u67e5\u5b89\u88c5\u662f\u5426\u6210\u529f\u3002<\/p>\n<p><strong>\u6211\u53ef\u4ee5\u5728\u54ea\u4e9b\u5e73\u53f0\u4e0a\u627e\u5230Python\u5c0f\u6e38\u620f\uff1f<\/strong><br \/>\u6709\u8bb8\u591a\u7f51\u7ad9\u548c\u793e\u533a\u63d0\u4f9bPython\u5c0f\u6e38\u620f\uff0c\u4f8b\u5982GitHub\u3001Pygame\u5b98\u65b9\u7f51\u7ad9\u4ee5\u53ca\u5404\u79cd\u7f16\u7a0b\u5b66\u4e60\u5e73\u53f0\u3002\u5728\u8fd9\u4e9b\u5e73\u53f0\u4e0a\uff0c\u60a8\u53ef\u4ee5\u627e\u5230\u73b0\u6210\u7684\u6e38\u620f\u6e90\u4ee3\u7801\uff0c\u6216\u8005\u4e0b\u8f7d\u4e00\u4e9b\u5f00\u6e90\u6e38\u620f\u9879\u76ee\uff0c\u8fdb\u884c\u5b66\u4e60\u548c\u4fee\u6539\u3002<\/p>\n<p><strong>\u5982\u4f55\u8fd0\u884c\u4e0b\u8f7d\u7684Python\u5c0f\u6e38\u620f\uff1f<\/strong><br \/>\u4e0b\u8f7dPython\u5c0f\u6e38\u620f\u540e\uff0c\u60a8\u9700\u8981\u5c06\u6587\u4ef6\u89e3\u538b\u7f29\u5e76\u786e\u4fdd\u6240\u6709\u4f9d\u8d56\u5e93\u90fd\u5df2\u7ecf\u5b89\u88c5\u3002\u901a\u5e38\uff0c\u6e38\u620f\u6587\u4ef6\u5939\u4e2d\u4f1a\u5305\u542b\u4e00\u4e2a<code>requirements.txt<\/code>\u6587\u4ef6\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u4f7f\u7528<code>pip install -r requirements.txt<\/code>\u6765\u5b89\u88c5\u6240\u9700\u7684\u4f9d\u8d56\u9879\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u5bfc\u822a\u5230\u6e38\u620f\u76ee\u5f55\uff0c\u5e76\u8fd0\u884c<code>python game.py<\/code>\uff08\u6216\u76f8\u5e94\u7684\u4e3b\u6587\u4ef6\u540d\uff09\u6765\u542f\u52a8\u6e38\u620f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u6253\u5f00Python\u5c0f\u6e38\u620f\u7684\u6b65\u9aa4\u4e3b\u8981\u5305\u62ec\u4e0b\u8f7d\u6e38\u620f\u4ee3\u7801\u3001\u5b89\u88c5Python\u73af\u5883\u3001\u8fd0\u884c\u6e38\u620f\u811a\u672c\u3002\u5176\u4e2d\uff0c\u5b89\u88c5Python\u73af [&hellip;]","protected":false},"author":3,"featured_media":990183,"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\/990171"}],"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=990171"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/990171\/revisions"}],"predecessor-version":[{"id":990186,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/990171\/revisions\/990186"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/990183"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=990171"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=990171"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=990171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}