{"id":1084699,"date":"2025-01-08T13:09:36","date_gmt":"2025-01-08T05:09:36","guid":{"rendered":""},"modified":"2025-01-08T13:09:39","modified_gmt":"2025-01-08T05:09:39","slug":"python-%e5%a6%82%e4%bd%95%e5%9c%a8dos%e5%91%bd%e4%bb%a4%e8%a1%8c%e7%aa%97%e5%8f%a3-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1084699.html","title":{"rendered":"python \u5982\u4f55\u5728dos\u547d\u4ee4\u884c\u7a97\u53e3"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24194926\/3a5c8167-ff07-46e9-aea7-5fd02ec481a3.webp\" alt=\"python \u5982\u4f55\u5728dos\u547d\u4ee4\u884c\u7a97\u53e3\" \/><\/p>\n<p><p> \u5f00\u5934\u6bb5\u843d\uff1a<\/p>\n<p><strong>Python \u5728 DOS \u547d\u4ee4\u884c\u7a97\u53e3\u4e2d\u4f7f\u7528\u975e\u5e38\u7b80\u5355\u3001\u5b89\u88c5Python\u3001\u4f7f\u7528Python\u89e3\u91ca\u5668\u3001\u8fd0\u884cPython\u811a\u672c\u3001\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<\/strong>\u3002\u6700\u91cd\u8981\u7684\u4e00\u6b65\u662f\u5b89\u88c5 Python\uff0c\u5e76\u786e\u4fdd\u6b63\u786e\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u3002\u901a\u8fc7\u6b63\u786e\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u60a8\u53ef\u4ee5\u5728\u4efb\u4f55\u5730\u65b9\u76f4\u63a5\u4f7f\u7528 <code>python<\/code> \u547d\u4ee4\u6765\u8c03\u7528 Python \u89e3\u91ca\u5668\u6216\u8fd0\u884c Python \u811a\u672c\uff0c\u8fd9\u5927\u5927\u65b9\u4fbf\u4e86\u5f00\u53d1\u548c\u8c03\u8bd5\u5de5\u4f5c\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u9010\u6b65\u4ecb\u7ecd\u5982\u4f55\u5728 DOS \u547d\u4ee4\u884c\u7a97\u53e3\u4e2d\u4f7f\u7528 Python\uff0c\u5305\u62ec\u5b89\u88c5\u3001\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u3001\u4f7f\u7528 Python \u89e3\u91ca\u5668\u4ee5\u53ca\u8fd0\u884c Python \u811a\u672c\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u5b89\u88c5 Python<\/p>\n<\/p>\n<p><p>\u8981\u5728 DOS \u547d\u4ee4\u884c\u7a97\u53e3\u4e2d\u4f7f\u7528 Python\uff0c\u9996\u5148\u9700\u8981\u5728\u60a8\u7684\u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5 Python\u3002Python \u63d0\u4f9b\u4e86\u4e00\u4e2a\u6613\u4e8e\u4f7f\u7528\u7684\u5b89\u88c5\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u4ece\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u3002<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00 Python \u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/www.python.org\/%EF%BC%89%E3%80%82\">https:\/\/www.python.org\/\uff09\u3002<\/a><\/li>\n<li>\u5728\u4e0b\u8f7d\u9875\u9762\u4e2d\uff0c\u9009\u62e9\u9002\u5408\u60a8\u64cd\u4f5c\u7cfb\u7edf\u7684\u7248\u672c\u8fdb\u884c\u4e0b\u8f7d\u3002\u5efa\u8bae\u9009\u62e9\u6700\u65b0\u7684\u7a33\u5b9a\u7248\u672c\u3002<\/li>\n<li>\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f\u3002\u786e\u4fdd\u52fe\u9009\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u8fd9\u6837\u53ef\u4ee5\u81ea\u52a8\u5c06 Python \u6dfb\u52a0\u5230\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u4e2d\u3002<\/li>\n<li>\u6309\u7167\u5b89\u88c5\u7a0b\u5e8f\u7684\u63d0\u793a\u5b8c\u6210\u5b89\u88c5\u3002<\/li>\n<\/ol>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u7a97\u53e3\u4e2d\u8f93\u5165 <code>python --version<\/code> \u6765\u9a8c\u8bc1 Python \u662f\u5426\u5df2\u6b63\u786e\u5b89\u88c5\u3002\u5982\u679c\u5b89\u88c5\u6210\u529f\uff0c\u60a8\u5c06\u770b\u5230 Python \u7684\u7248\u672c\u53f7\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<\/p>\n<\/p>\n<p><p>\u5982\u679c\u5728\u5b89\u88c5 Python \u65f6\u6ca1\u6709\u52fe\u9009\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u6216\u8005\u60a8\u9700\u8981\u624b\u52a8\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u53ef\u4ee5\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u64cd\u4f5c\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u53f3\u952e\u5355\u51fb\u201c\u6b64\u7535\u8111\u201d\u6216\u201c\u8ba1\u7b97\u673a\u201d\u56fe\u6807\uff0c\u7136\u540e\u9009\u62e9\u201c\u5c5e\u6027\u201d\u3002<\/li>\n<li>\u5728\u7cfb\u7edf\u5c5e\u6027\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d\u3002<\/li>\n<li>\u5728\u201c\u7cfb\u7edf\u5c5e\u6027\u201d\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u201c\u73af\u5883\u53d8\u91cf\u201d\u6309\u94ae\u3002<\/li>\n<li>\u5728\u201c\u73af\u5883\u53d8\u91cf\u201d\u7a97\u53e3\u4e2d\uff0c\u627e\u5230\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u90e8\u5206\uff0c\u9009\u62e9\u201cPath\u201d\u53d8\u91cf\uff0c\u7136\u540e\u70b9\u51fb\u201c\u7f16\u8f91\u201d\u6309\u94ae\u3002<\/li>\n<li>\u5728\u201c\u7f16\u8f91\u73af\u5883\u53d8\u91cf\u201d\u7a97\u53e3\u4e2d\uff0c\u70b9\u51fb\u201c\u65b0\u5efa\u201d\u6309\u94ae\uff0c\u7136\u540e\u8f93\u5165 Python \u5b89\u88c5\u76ee\u5f55\u7684\u8def\u5f84\u3002\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u5c06 Python \u5b89\u88c5\u5728 <code>C:\\Python39<\/code> \u76ee\u5f55\u4e2d\uff0c\u5219\u9700\u8981\u8f93\u5165 <code>C:\\Python39<\/code>\u3002<\/li>\n<li>\u70b9\u51fb\u201c\u786e\u5b9a\u201d\u6309\u94ae\u4fdd\u5b58\u66f4\u6539\u3002<\/li>\n<\/ol>\n<p><p>\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u540e\uff0c\u60a8\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u7a97\u53e3\u4e2d\u8f93\u5165 <code>python<\/code> \u6765\u542f\u52a8 Python \u89e3\u91ca\u5668\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001\u4f7f\u7528 Python \u89e3\u91ca\u5668<\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u548c\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u5728 DOS \u547d\u4ee4\u884c\u7a97\u53e3\u4e2d\u4f7f\u7528 Python \u89e3\u91ca\u5668\u3002\u53ea\u9700\u8f93\u5165 <code>python<\/code> \u547d\u4ee4\uff0c\u7136\u540e\u6309\u56de\u8f66\u952e\uff0c\u5373\u53ef\u8fdb\u5165 Python \u89e3\u91ca\u5668\u7684\u4ea4\u4e92\u6a21\u5f0f\u3002\u5728\u4ea4\u4e92\u6a21\u5f0f\u4e2d\uff0c\u60a8\u53ef\u4ee5\u8f93\u5165 Python \u4ee3\u7801\u5e76\u7acb\u5373\u67e5\u770b\u8f93\u51fa\u7ed3\u679c\u3002<\/p>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u60a8\u53ef\u4ee5\u8f93\u5165\u4ee5\u4e0b\u4ee3\u7801\u6765\u8ba1\u7b97\u4e00\u4e2a\u7b80\u5355\u7684\u6570\u5b66\u8868\u8fbe\u5f0f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">&gt;&gt;&gt; 2 + 2<\/p>\n<p>4<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>Python \u89e3\u91ca\u5668\u4f1a\u7acb\u5373\u6267\u884c\u4ee3\u7801\u5e76\u663e\u793a\u7ed3\u679c\u3002\u8fd9\u79cd\u4ea4\u4e92\u6a21\u5f0f\u975e\u5e38\u9002\u5408\u7528\u4e8e\u8c03\u8bd5\u548c\u6d4b\u8bd5\u4ee3\u7801\u7247\u6bb5\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u8fd0\u884c Python \u811a\u672c<\/p>\n<\/p>\n<p><p>\u9664\u4e86\u5728\u4ea4\u4e92\u6a21\u5f0f\u4e2d\u6267\u884c\u4ee3\u7801\uff0c\u60a8\u8fd8\u53ef\u4ee5\u5728 DOS \u547d\u4ee4\u884c\u7a97\u53e3\u4e2d\u8fd0\u884c Python \u811a\u672c\u3002Python \u811a\u672c\u662f\u4e00\u79cd\u5305\u542b Python \u4ee3\u7801\u7684\u6587\u672c\u6587\u4ef6\uff0c\u901a\u5e38\u4ee5 <code>.py<\/code> \u6269\u5c55\u540d\u7ed3\u5c3e\u3002<\/p>\n<\/p>\n<p><p>\u8981\u8fd0\u884c Python \u811a\u672c\uff0c\u60a8\u9700\u8981\u9996\u5148\u521b\u5efa\u4e00\u4e2a\u811a\u672c\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a <code>hello.py<\/code> \u7684\u6587\u4ef6\uff0c\u5e76\u5728\u5176\u4e2d\u8f93\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">print(&quot;Hello, World!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4fdd\u5b58\u6587\u4ef6\u540e\uff0c\u6253\u5f00 DOS \u547d\u4ee4\u884c\u7a97\u53e3\uff0c\u5bfc\u822a\u5230\u811a\u672c\u6587\u4ef6\u6240\u5728\u7684\u76ee\u5f55\uff0c\u7136\u540e\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u8fd0\u884c\u811a\u672c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">python hello.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>DOS \u547d\u4ee4\u884c\u7a97\u53e3\u5c06\u6267\u884c\u811a\u672c\u5e76\u663e\u793a\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-shell\">Hello, World!<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e94\u3001\u5e38\u7528\u547d\u4ee4\u548c\u6280\u5de7<\/p>\n<\/p>\n<p><p>\u5728 DOS \u547d\u4ee4\u884c\u7a97\u53e3\u4e2d\u4f7f\u7528 Python \u65f6\uff0c\u60a8\u53ef\u80fd\u4f1a\u7ecf\u5e38\u4f7f\u7528\u4e00\u4e9b\u547d\u4ee4\u548c\u6280\u5de7\u6765\u63d0\u9ad8\u5de5\u4f5c\u6548\u7387\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u67e5\u770b Python \u7248\u672c<\/strong>\uff1a\u4f7f\u7528 <code>python --version<\/code> \u547d\u4ee4\u53ef\u4ee5\u67e5\u770b\u5f53\u524d\u5b89\u88c5\u7684 Python \u7248\u672c\u3002<\/li>\n<li><strong>\u9000\u51fa Python \u89e3\u91ca\u5668<\/strong>\uff1a\u5728 Python \u89e3\u91ca\u5668\u4e2d\uff0c\u8f93\u5165 <code>exit()<\/code> \u6216\u6309 <code>Ctrl + Z<\/code>\uff08Windows\uff09\u6216 <code>Ctrl + D<\/code>\uff08Mac\/Linux\uff09\u53ef\u4ee5\u9000\u51fa\u89e3\u91ca\u5668\u3002<\/li>\n<li><strong>\u5b89\u88c5\u5305\u548c\u6a21\u5757<\/strong>\uff1a\u4f7f\u7528 <code>pip<\/code> \u547d\u4ee4\u53ef\u4ee5\u5b89\u88c5\u548c\u7ba1\u7406 Python \u5305\u3002\u4f8b\u5982\uff0c\u4f7f\u7528 <code>pip install requests<\/code> \u53ef\u4ee5\u5b89\u88c5 <code>requests<\/code> \u6a21\u5757\u3002<\/li>\n<li><strong>\u8fd0\u884c\u811a\u672c\u65f6\u4f20\u9012\u53c2\u6570<\/strong>\uff1a\u53ef\u4ee5\u5728\u8fd0\u884c\u811a\u672c\u65f6\u4f20\u9012\u53c2\u6570\u3002\u4f8b\u5982\uff0c\u8f93\u5165 <code>python script.py arg1 arg2<\/code> \u53ef\u4ee5\u5c06 <code>arg1<\/code> \u548c <code>arg2<\/code> \u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9 <code>script.py<\/code>\u3002<\/li>\n<\/ol>\n<p><p>\u516d\u3001\u8c03\u8bd5\u548c\u9519\u8bef\u5904\u7406<\/p>\n<\/p>\n<p><p>\u5728\u5f00\u53d1 Python \u7a0b\u5e8f\u65f6\uff0c\u8c03\u8bd5\u548c\u9519\u8bef\u5904\u7406\u662f\u975e\u5e38\u91cd\u8981\u7684\u73af\u8282\u3002Python \u63d0\u4f9b\u4e86\u591a\u79cd\u8c03\u8bd5\u5de5\u5177\u548c\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5e2e\u52a9\u60a8\u5feb\u901f\u5b9a\u4f4d\u548c\u4fee\u590d\u95ee\u9898\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u4f7f\u7528 print \u8bed\u53e5<\/strong>\uff1a\u5728\u4ee3\u7801\u4e2d\u63d2\u5165 <code>print<\/code> \u8bed\u53e5\u53ef\u4ee5\u67e5\u770b\u53d8\u91cf\u7684\u503c\u548c\u7a0b\u5e8f\u7684\u6267\u884c\u6d41\u7a0b\u3002\u8fd9\u662f\u6700\u7b80\u5355\u7684\u8c03\u8bd5\u65b9\u6cd5\u3002<\/li>\n<li><strong>\u4f7f\u7528 pdb \u8c03\u8bd5\u5668<\/strong>\uff1aPython \u5185\u7f6e\u7684 <code>pdb<\/code> \u8c03\u8bd5\u5668\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u8c03\u8bd5\u529f\u80fd\u3002\u53ef\u4ee5\u5728\u4ee3\u7801\u4e2d\u63d2\u5165 <code>import pdb; pdb.set_trace()<\/code> \u6765\u542f\u52a8\u8c03\u8bd5\u5668\uff0c\u7136\u540e\u9010\u884c\u6267\u884c\u4ee3\u7801\u3002<\/li>\n<li><strong>\u6355\u83b7\u5f02\u5e38<\/strong>\uff1a\u4f7f\u7528 <code>try-except<\/code> \u8bed\u53e5\u53ef\u4ee5\u6355\u83b7\u548c\u5904\u7406\u5f02\u5e38\u3002\u4f8b\u5982\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">try:<\/p>\n<p>    x = 1 \/ 0<\/p>\n<p>except ZeroDivisionError:<\/p>\n<p>    print(&quot;\u4e0d\u80fd\u9664\u4ee5\u96f6&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"4\">\n<li><strong>\u67e5\u770b\u9519\u8bef\u5806\u6808\u4fe1\u606f<\/strong>\uff1a\u5f53\u7a0b\u5e8f\u53d1\u751f\u9519\u8bef\u65f6\uff0cPython \u4f1a\u663e\u793a\u9519\u8bef\u5806\u6808\u4fe1\u606f\u3002\u60a8\u53ef\u4ee5\u6839\u636e\u5806\u6808\u4fe1\u606f\u5b9a\u4f4d\u9519\u8bef\u7684\u5177\u4f53\u4f4d\u7f6e\u3002<\/li>\n<\/ol>\n<p><p>\u4e03\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883<\/p>\n<\/p>\n<p><p>\u5728\u5f00\u53d1 Python \u9879\u76ee\u65f6\uff0c\u4f7f\u7528\u865a\u62df\u73af\u5883\u53ef\u4ee5\u9694\u79bb\u9879\u76ee\u7684\u4f9d\u8d56\u5173\u7cfb\uff0c\u907f\u514d\u4f9d\u8d56\u51b2\u7a81\u3002Python \u63d0\u4f9b\u4e86 <code>venv<\/code> \u6a21\u5757\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u521b\u5efa\u548c\u7ba1\u7406\u865a\u62df\u73af\u5883\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u521b\u5efa\u865a\u62df\u73af\u5883<\/strong>\uff1a\u5728\u9879\u76ee\u76ee\u5f55\u4e2d\u8fd0\u884c <code>python -m venv env<\/code> \u547d\u4ee4\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a <code>env<\/code> \u7684\u865a\u62df\u73af\u5883\u3002<\/li>\n<li><strong>\u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/strong>\uff1a\u5728 Windows \u4e0a\uff0c\u8fd0\u884c <code>env\\Scripts\\activate<\/code> \u547d\u4ee4\u53ef\u4ee5\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u3002\u5728 Mac\/Linux \u4e0a\uff0c\u8fd0\u884c <code>source env\/bin\/activate<\/code> \u547d\u4ee4\u3002<\/li>\n<li><strong>\u5b89\u88c5\u4f9d\u8d56\u5305<\/strong>\uff1a\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>pip<\/code> \u547d\u4ee4\u5b89\u88c5\u9879\u76ee\u6240\u9700\u7684\u4f9d\u8d56\u5305\u3002\u4f8b\u5982\uff0c\u8fd0\u884c <code>pip install requests<\/code>\u3002<\/li>\n<li><strong>\u9000\u51fa\u865a\u62df\u73af\u5883<\/strong>\uff1a\u8fd0\u884c <code>deactivate<\/code> \u547d\u4ee4\u53ef\u4ee5\u9000\u51fa\u865a\u62df\u73af\u5883\u3002<\/li>\n<\/ol>\n<p><p>\u516b\u3001\u4f7f\u7528 IDLE \u548c\u5176\u4ed6 IDE<\/p>\n<\/p>\n<p><p>\u867d\u7136 DOS \u547d\u4ee4\u884c\u7a97\u53e3\u63d0\u4f9b\u4e86\u57fa\u672c\u7684 Python \u4ea4\u4e92\u548c\u811a\u672c\u8fd0\u884c\u529f\u80fd\uff0c\u4f46\u5bf9\u4e8e\u590d\u6742\u7684\u5f00\u53d1\u4efb\u52a1\uff0c\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u53ef\u4ee5\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u3002Python \u9644\u5e26\u4e86\u4e00\u4e2a\u7b80\u5355\u7684 IDE\uff0c\u79f0\u4e3a IDLE\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u542f\u52a8 IDLE<\/strong>\uff1a\u5728\u547d\u4ee4\u884c\u7a97\u53e3\u4e2d\u8f93\u5165 <code>idle<\/code> \u547d\u4ee4\u53ef\u4ee5\u542f\u52a8 IDLE\u3002IDLE \u63d0\u4f9b\u4e86\u4e00\u4e2a\u56fe\u5f62\u754c\u9762\u7684\u7f16\u8f91\u5668\u548c\u4ea4\u4e92\u89e3\u91ca\u5668\uff0c\u9002\u5408\u7528\u4e8e\u7f16\u5199\u548c\u8c03\u8bd5\u4ee3\u7801\u3002<\/li>\n<li><strong>\u5176\u4ed6 IDE<\/strong>\uff1a\u9664\u4e86 IDLE\uff0c\u8fd8\u6709\u8bb8\u591a\u529f\u80fd\u5f3a\u5927\u7684 IDE \u53ef\u4f9b\u9009\u62e9\uff0c\u4f8b\u5982 PyCharm\u3001Visual Studio Code\u3001Sublime Text \u7b49\u3002\u8fd9\u4e9b IDE \u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u529f\u80fd\uff0c\u5305\u62ec\u4ee3\u7801\u81ea\u52a8\u8865\u5168\u3001\u8c03\u8bd5\u5668\u3001\u7248\u672c\u63a7\u5236\u96c6\u6210\u7b49\u3002<\/li>\n<\/ol>\n<p><p>\u4e5d\u3001\u5b66\u4e60\u8d44\u6e90\u548c\u793e\u533a<\/p>\n<\/p>\n<p><p>\u5b66\u4e60 Python \u662f\u4e00\u4e2a\u6301\u7eed\u7684\u8fc7\u7a0b\uff0c\u501f\u52a9\u4e30\u5bcc\u7684\u5b66\u4e60\u8d44\u6e90\u548c\u793e\u533a\u652f\u6301\uff0c\u60a8\u53ef\u4ee5\u4e0d\u65ad\u63d0\u5347\u81ea\u5df1\u7684\u6280\u80fd\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u5b98\u65b9\u6587\u6863<\/strong>\uff1aPython \u5b98\u65b9\u6587\u6863\uff08<a href=\"https:\/\/docs.python.org\/%EF%BC%89%E6%98%AF%E5%AD%A6%E4%B9%A0%E5%92%8C%E5%8F%82%E8%80%83\">https:\/\/docs.python.org\/\uff09\u662f\u5b66\u4e60\u548c\u53c2\u8003<\/a> Python \u7684\u6700\u4f73\u8d44\u6e90\u3002\u6587\u6863\u6db5\u76d6\u4e86 Python \u7684\u6240\u6709\u65b9\u9762\uff0c\u5305\u62ec\u6807\u51c6\u5e93\u3001\u8bed\u8a00\u89c4\u8303\u548c\u793a\u4f8b\u4ee3\u7801\u3002<\/li>\n<li><strong>\u5728\u7ebf\u6559\u7a0b<\/strong>\uff1a\u4e92\u8054\u7f51\u4e0a\u6709\u8bb8\u591a\u4f18\u8d28\u7684 Python \u6559\u7a0b\u548c\u8bfe\u7a0b\u3002\u4f8b\u5982\uff0cCodecademy\u3001Coursera\u3001edX \u7b49\u5e73\u53f0\u63d0\u4f9b\u4e86\u514d\u8d39\u7684 Python \u6559\u7a0b\u3002<\/li>\n<li><strong>\u8bba\u575b\u548c\u793e\u533a<\/strong>\uff1a\u53c2\u4e0e Python \u793e\u533a\u53ef\u4ee5\u83b7\u5f97\u5e2e\u52a9\u548c\u652f\u6301\u3002\u4f8b\u5982\uff0cStack Overflow\u3001Reddit \u7684 r\/learnpython \u677f\u5757\u3001Python \u8ba8\u8bba\u90ae\u4ef6\u5217\u8868\u7b49\u90fd\u662f\u6d3b\u8dc3\u7684\u793e\u533a\u3002<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\u548c\u6280\u5de7\uff0c\u60a8\u53ef\u4ee5\u5728 DOS \u547d\u4ee4\u884c\u7a97\u53e3\u4e2d\u9ad8\u6548\u5730\u4f7f\u7528 Python \u8fdb\u884c\u5f00\u53d1\u548c\u8c03\u8bd5\u3002\u5e0c\u671b\u8fd9\u4e9b\u5185\u5bb9\u5bf9\u60a8\u6709\u6240\u5e2e\u52a9\uff0c\u795d\u60a8\u5728\u5b66\u4e60\u548c\u4f7f\u7528 Python \u7684\u8fc7\u7a0b\u4e2d\u53d6\u5f97\u6210\u529f\uff01<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5728DOS\u547d\u4ee4\u884c\u7a97\u53e3\u4e2d\u5982\u4f55\u8fd0\u884cPython\u811a\u672c\uff1f<\/strong><br \/>\u60a8\u53ef\u4ee5\u5728DOS\u547d\u4ee4\u884c\u7a97\u53e3\u4e2d\u8fd0\u884cPython\u811a\u672c\uff0c\u53ea\u9700\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u4f7f\u7528<code>cd<\/code>\u547d\u4ee4\u5bfc\u822a\u5230\u5305\u542bPython\u811a\u672c\u7684\u76ee\u5f55\uff0c\u7136\u540e\u8f93\u5165<code>python script_name.py<\/code>\u6765\u6267\u884c\u8be5\u811a\u672c\u3002\u786e\u4fdd\u5df2\u7ecf\u5b89\u88c5\u4e86Python\uff0c\u5e76\u4e14\u5176\u8def\u5f84\u5df2\u6dfb\u52a0\u5230\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u4e2d\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Windows\u547d\u4ee4\u884c\u4e2d\u68c0\u67e5Python\u662f\u5426\u5b89\u88c5\uff1f<\/strong><br \/>\u8981\u68c0\u67e5Python\u662f\u5426\u5df2\u5b89\u88c5\uff0c\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u5e76\u8f93\u5165<code>python --version<\/code>\u6216<code>python -V<\/code>\u3002\u5982\u679cPython\u5df2\u6b63\u786e\u5b89\u88c5\uff0c\u60a8\u5c06\u770b\u5230\u5f53\u524d\u7684Python\u7248\u672c\u53f7\u3002\u5982\u679c\u51fa\u73b0\u201c\u672a\u627e\u5230\u547d\u4ee4\u201d\u6216\u7c7b\u4f3c\u7684\u63d0\u793a\uff0c\u53ef\u80fd\u9700\u8981\u5b89\u88c5Python\u6216\u68c0\u67e5\u73af\u5883\u53d8\u91cf\u8bbe\u7f6e\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728\u547d\u4ee4\u884c\u4e2d\u4f7f\u7528Python\u7684\u865a\u62df\u73af\u5883\uff1f<\/strong><br \/>\u5728\u547d\u4ee4\u884c\u4e2d\u4f7f\u7528\u865a\u62df\u73af\u5883\u53ef\u4ee5\u5e2e\u52a9\u60a8\u7ba1\u7406\u9879\u76ee\u4f9d\u8d56\u3002\u53ef\u4ee5\u4f7f\u7528<code>python -m venv env_name<\/code>\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>env_name<\/code>\u7684\u865a\u62df\u73af\u5883\u3002\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u7684\u65b9\u6cd5\u662f\uff1a\u5728Windows\u4e0a\u4f7f\u7528<code>env_name\\Scripts\\activate<\/code>\uff0c\u5728Linux\u6216macOS\u4e0a\u4f7f\u7528<code>source env_name\/bin\/activate<\/code>\u3002\u6fc0\u6d3b\u540e\uff0c\u60a8\u53ef\u4ee5\u5728\u8be5\u73af\u5883\u4e2d\u5b89\u88c5\u6240\u9700\u7684\u5305\uff0c\u5e76\u786e\u4fdd\u4e0d\u4f1a\u5f71\u54cd\u5168\u5c40Python\u5b89\u88c5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5f00\u5934\u6bb5\u843d\uff1a Python \u5728 DOS \u547d\u4ee4\u884c\u7a97\u53e3\u4e2d\u4f7f\u7528\u975e\u5e38\u7b80\u5355\u3001\u5b89\u88c5Python\u3001\u4f7f\u7528Python\u89e3\u91ca\u5668\u3001\u8fd0\u884c [&hellip;]","protected":false},"author":3,"featured_media":1084711,"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\/1084699"}],"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=1084699"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1084699\/revisions"}],"predecessor-version":[{"id":1084712,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1084699\/revisions\/1084712"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1084711"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1084699"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1084699"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1084699"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}