{"id":922162,"date":"2024-12-26T14:26:46","date_gmt":"2024-12-26T06:26:46","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/922162.html"},"modified":"2024-12-26T14:26:47","modified_gmt":"2024-12-26T06:26:47","slug":"%e5%a6%82%e4%bd%95%e7%94%a8cmd%e6%89%93%e5%bc%80python","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/922162.html","title":{"rendered":"\u5982\u4f55\u7528cmd\u6253\u5f00python"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24210804\/e8761028-2769-4af7-9ae5-99aabfbfa33b.webp\" alt=\"\u5982\u4f55\u7528cmd\u6253\u5f00python\" \/><\/p>\n<p><p> <strong>\u5728Windows\u64cd\u4f5c\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u63d0\u793a\u7b26\uff08CMD\uff09\u6253\u5f00Python\u3002\u9996\u5148\uff0c\u786e\u4fdd\u4f60\u7684\u8ba1\u7b97\u673a\u4e0a\u5df2\u7ecf\u5b89\u88c5\u4e86Python\uff0c\u5e76\u4e14\u73af\u5883\u53d8\u91cf\u8bbe\u7f6e\u6b63\u786e\u3002\u4ee5\u4e0b\u662f\u6253\u5f00Python\u7684\u6b65\u9aa4\uff1a\u6309\u4e0b\u952e\u76d8\u4e0a\u7684Win + R\u952e\uff0c\u5728\u8fd0\u884c\u6846\u4e2d\u8f93\u5165\u201ccmd\u201d\u5e76\u6309Enter\u952e\u3001\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165\u201cpython\u201d\u5e76\u6309\u4e0bEnter\u952e\u3001\u5982\u679c\u73af\u5883\u53d8\u91cf\u8bbe\u7f6e\u6b63\u786e\uff0c\u5c06\u4f1a\u8fdb\u5165Python\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\u3002<\/strong>\u786e\u4fdd\u73af\u5883\u53d8\u91cf\u914d\u7f6e\u6b63\u786e\u662f\u5173\u952e\u7684\u4e00\u6b65\uff0c\u56e0\u4e3a\u8fd9\u51b3\u5b9a\u4e86\u4f60\u80fd\u5426\u76f4\u63a5\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u4f7f\u7528\u201cpython\u201d\u547d\u4ee4\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u5b89\u88c5Python\u53ca\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/p>\n<\/p>\n<p><p>\u5728\u4f7f\u7528CMD\u6253\u5f00Python\u4e4b\u524d\uff0c\u5fc5\u987b\u786e\u4fddPython\u5df2\u7ecf\u5b89\u88c5\u5728\u4f60\u7684\u8ba1\u7b97\u673a\u4e0a\u3002\u5982\u679c\u5c1a\u672a\u5b89\u88c5\uff0c\u53ef\u4ee5\u8bbf\u95eePython\u7684\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u6700\u65b0\u7684\u5b89\u88c5\u7a0b\u5e8f\u3002\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f\u5e76\u52fe\u9009\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u8fd9\u5c06\u81ea\u52a8\u4e3a\u4f60\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3002\u73af\u5883\u53d8\u91cf\u662f\u64cd\u4f5c\u7cfb\u7edf\u7528\u6765\u6307\u5b9a\u7cfb\u7edf\u6216\u5e94\u7528\u7a0b\u5e8f\u7684\u8fd0\u884c\u73af\u5883\u7684\u4e00\u4e2a\u91cd\u8981\u8bbe\u7f6e\uff0c\u5b83\u5141\u8bb8\u4f60\u5728\u4efb\u610f\u76ee\u5f55\u4e0b\u76f4\u63a5\u8fd0\u884cPython\u547d\u4ee4\u3002<\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165\u201cpython &#8211;version\u201d\u6765\u9a8c\u8bc1Python\u662f\u5426\u6b63\u786e\u5b89\u88c5\u548c\u914d\u7f6e\u3002\u5982\u679c\u547d\u4ee4\u8fd4\u56dePython\u7684\u7248\u672c\u53f7\uff0c\u5219\u8bf4\u660e\u5b89\u88c5\u6210\u529f\uff0c\u73af\u5883\u53d8\u91cf\u914d\u7f6e\u6b63\u786e\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u4f7f\u7528CMD\u6253\u5f00Python<\/p>\n<\/p>\n<ol>\n<li>\n<p>\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff1a\u6309\u4e0b\u952e\u76d8\u4e0a\u7684Win + R\u7ec4\u5408\u952e\uff0c\u8f93\u5165\u201ccmd\u201d\u5e76\u6309Enter\u952e\u3002\u8fd9\u5c06\u6253\u5f00Windows\u7684\u547d\u4ee4\u63d0\u793a\u7b26\u7a97\u53e3\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u8f93\u5165Python\u547d\u4ee4\uff1a\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u7a97\u53e3\u4e2d\u8f93\u5165\u201cpython\u201d\u5e76\u6309\u4e0bEnter\u952e\u3002\u5982\u679c\u73af\u5883\u53d8\u91cf\u8bbe\u7f6e\u6b63\u786e\uff0c\u4f60\u5c06\u770b\u5230Python\u7684\u7248\u672c\u4fe1\u606f\uff0c\u5e76\u8fdb\u5165Python\u7684\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\u3002\u6b64\u65f6\uff0c\u4f60\u53ef\u4ee5\u5728\u63d0\u793a\u7b26\u4e0b\u8f93\u5165Python\u4ee3\u7801\u5e76\u7acb\u5373\u6267\u884c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u9000\u51faPython\u89e3\u91ca\u5668\uff1a\u8981\u9000\u51faPython\u7684\u4ea4\u4e92\u6a21\u5f0f\uff0c\u53ef\u4ee5\u8f93\u5165\u201cexit()\u201d\u6216\u6309\u4e0bCtrl + Z\uff0c\u7136\u540e\u6309Enter\u952e\u3002\u8fd9\u5c06\u8fd4\u56de\u5230\u547d\u4ee4\u63d0\u793a\u7b26\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6cd5<\/p>\n<\/p>\n<p><p>\u6709\u65f6\u5019\uff0c\u5373\u4fbf\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86Python\u5e76\u914d\u7f6e\u4e86\u73af\u5883\u53d8\u91cf\uff0c\u4f60\u4ecd\u53ef\u80fd\u4f1a\u5728CMD\u4e2d\u9047\u5230\u65e0\u6cd5\u6253\u5f00Python\u7684\u95ee\u9898\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u95ee\u9898\u53ca\u5176\u89e3\u51b3\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u73af\u5883\u53d8\u91cf\u672a\u8bbe\u7f6e<\/strong>\uff1a\u5982\u679c\u5728CMD\u4e2d\u8f93\u5165\u201cpython\u201d\u540e\u663e\u793a\u201c\u4e0d\u662f\u5185\u90e8\u6216\u5916\u90e8\u547d\u4ee4\u201d\uff0c\u53ef\u80fd\u662f\u56e0\u4e3a\u73af\u5883\u53d8\u91cf\u672a\u6b63\u786e\u8bbe\u7f6e\u3002\u4f60\u53ef\u4ee5\u624b\u52a8\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff1a\u53f3\u952e\u5355\u51fb\u201c\u8ba1\u7b97\u673a\u201d\u56fe\u6807\uff0c\u9009\u62e9\u201c\u5c5e\u6027\u201d\uff0c\u7136\u540e\u70b9\u51fb\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d\u3002\u5728\u201c\u7cfb\u7edf\u5c5e\u6027\u201d\u7a97\u53e3\u4e2d\uff0c\u9009\u62e9\u201c\u73af\u5883\u53d8\u91cf\u201d\uff0c\u7136\u540e\u5728\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u4e2d\u627e\u5230\u5e76\u7f16\u8f91\u201cPath\u201d\u53d8\u91cf\uff0c\u6dfb\u52a0Python\u7684\u5b89\u88c5\u8def\u5f84\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7248\u672c\u51b2\u7a81<\/strong>\uff1a\u5982\u679c\u4f60\u7684\u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5\u4e86\u591a\u4e2a\u7248\u672c\u7684Python\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4CMD\u4e2d\u8c03\u7528\u7684\u7248\u672c\u4e0d\u6b63\u786e\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u660e\u786e\u6307\u5b9aPython\u7684\u8def\u5f84\u6765\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u3002\u4f8b\u5982\uff0c\u8f93\u5165\u201cC:\\Python39\\python.exe\u201d\u4ee5\u8fd0\u884c\u7279\u5b9a\u7248\u672c\u7684Python\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6743\u9650\u95ee\u9898<\/strong>\uff1a\u6709\u65f6\u6743\u9650\u8bbe\u7f6e\u53ef\u80fd\u4f1a\u963b\u6b62\u547d\u4ee4\u63d0\u793a\u7b26\u8bbf\u95eePython\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u4ee5\u5c1d\u8bd5\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u8fd0\u884c\u547d\u4ee4\u63d0\u793a\u7b26\uff1a\u53f3\u952e\u5355\u51fbCMD\u56fe\u6807\uff0c\u9009\u62e9\u201c\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u8fd0\u884c\u201d\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u5728CMD\u4e2d\u6267\u884cPython\u811a\u672c<\/p>\n<\/p>\n<p><p>\u9664\u4e86\u8fdb\u5165Python\u7684\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\uff0c\u4f60\u8fd8\u53ef\u4ee5\u5728CMD\u4e2d\u76f4\u63a5\u8fd0\u884cPython\u811a\u672c\u3002\u8fd9\u5728\u5f00\u53d1\u548c\u8c03\u8bd5Python\u7a0b\u5e8f\u65f6\u975e\u5e38\u6709\u7528\u3002\u4ee5\u4e0b\u662f\u6267\u884cPython\u811a\u672c\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u521b\u5efaPython\u811a\u672c\uff1a\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\uff08\u5982Notepad++\u3001Sublime Text\u6216Visual Studio Code\uff09\u7f16\u5199Python\u4ee3\u7801\uff0c\u5e76\u5c06\u6587\u4ef6\u4fdd\u5b58\u4e3a\u201c.py\u201d\u6269\u5c55\u540d\u3002\u4f8b\u5982\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u4fdd\u5b58\u4e3a\u201chello.py\u201d\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">print(&quot;Hello, world!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li>\n<p>\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff1a\u6309Win + R\uff0c\u8f93\u5165\u201ccmd\u201d\u5e76\u6309Enter\u952e\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u5bfc\u822a\u5230\u811a\u672c\u6240\u5728\u76ee\u5f55\uff1a\u4f7f\u7528\u201ccd\u201d\u547d\u4ee4\u5bfc\u822a\u5230\u4fdd\u5b58Python\u811a\u672c\u7684\u76ee\u5f55\u3002\u4f8b\u5982\uff0c\u5982\u679c\u811a\u672c\u4fdd\u5b58\u5728\u201cC:\\Scripts\u201d\u76ee\u5f55\u4e0b\uff0c\u53ef\u4ee5\u8f93\u5165\u201ccd C:\\Scripts\u201d\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u8fd0\u884cPython\u811a\u672c\uff1a\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165\u201cpython hello.py\u201d\u5e76\u6309Enter\u952e\u3002\u8fd9\u5c06\u6267\u884c\u811a\u672c\u5e76\u5728\u63a7\u5236\u53f0\u4e2d\u8f93\u51fa\u7ed3\u679c\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u4f7f\u7528\u865a\u62df\u73af\u5883<\/p>\n<\/p>\n<p><p>\u5728Python\u5f00\u53d1\u4e2d\uff0c\u865a\u62df\u73af\u5883\u662f\u4e00\u4e2a\u975e\u5e38\u6709\u7528\u7684\u5de5\u5177\uff0c\u5b83\u5141\u8bb8\u4f60\u4e3a\u6bcf\u4e2a\u9879\u76ee\u521b\u5efa\u72ec\u7acb\u7684Python\u73af\u5883\uff0c\u4ece\u800c\u907f\u514d\u4e0d\u540c\u9879\u76ee\u4e4b\u95f4\u7684\u4f9d\u8d56\u51b2\u7a81\u3002\u4ee5\u4e0b\u662f\u521b\u5efa\u548c\u4f7f\u7528\u865a\u62df\u73af\u5883\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p>\u5b89\u88c5virtualenv\u5de5\u5177\uff1a\u5982\u679c\u4f60\u7684Python\u7248\u672c\u662f3.3\u6216\u66f4\u9ad8\u7248\u672c\uff0c\u5df2\u7ecf\u81ea\u5e26\u4e86venv\u6a21\u5757\uff0c\u4f60\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u5b83\u521b\u5efa\u865a\u62df\u73af\u5883\u3002\u5982\u679c\u662f\u8f83\u65e9\u7684\u7248\u672c\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u5728CMD\u4e2d\u8fd0\u884c\u201cpip install virtualenv\u201d\u6765\u5b89\u88c5virtualenv\u5de5\u5177\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u521b\u5efa\u865a\u62df\u73af\u5883\uff1a\u5bfc\u822a\u5230\u4f60\u7684\u9879\u76ee\u76ee\u5f55\uff0c\u7136\u540e\u8f93\u5165\u201cpython -m venv myenv\u201d\u6765\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a\u201cmyenv\u201d\u7684\u865a\u62df\u73af\u5883\u3002\u8fd9\u4e2a\u547d\u4ee4\u4f1a\u5728\u9879\u76ee\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u6587\u4ef6\u5939\uff0c\u5305\u542b\u8be5\u865a\u62df\u73af\u5883\u7684\u6240\u6709\u5fc5\u8981\u6587\u4ef6\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165\u201cmyenv\\Scripts\\activate\u201d\u6765\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u3002\u6fc0\u6d3b\u540e\uff0c\u547d\u4ee4\u63d0\u793a\u7b26\u4f1a\u663e\u793a\u865a\u62df\u73af\u5883\u7684\u540d\u79f0\uff0c\u8868\u793a\u4f60\u5f53\u524d\u6b63\u5728\u4f7f\u7528\u8fd9\u4e2a\u73af\u5883\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u5728\u865a\u62df\u73af\u5883\u4e2d\u8fd0\u884cPython\uff1a\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u4f60\u53ef\u4ee5\u50cf\u5728\u5168\u5c40\u73af\u5883\u4e2d\u4e00\u6837\u8fd0\u884cPython\u811a\u672c\u3002\u6b64\u65f6\uff0c\u6240\u6709\u7684Python\u5305\u5b89\u88c5\u548c\u811a\u672c\u6267\u884c\u90fd\u662f\u5728\u865a\u62df\u73af\u5883\u4e2d\u8fdb\u884c\u7684\uff0c\u4e0d\u4f1a\u5f71\u54cd\u5168\u5c40Python\u73af\u5883\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u9000\u51fa\u865a\u62df\u73af\u5883\uff1a\u8f93\u5165\u201cdeactivate\u201d\u547d\u4ee4\u53ef\u4ee5\u9000\u51fa\u5f53\u524d\u7684\u865a\u62df\u73af\u5883\uff0c\u8fd4\u56de\u5230\u5168\u5c40\u73af\u5883\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u516d\u3001\u4f7f\u7528CMD\u8fdb\u884cPython\u5f00\u53d1<\/p>\n<\/p>\n<p><p>\u547d\u4ee4\u63d0\u793a\u7b26\u4e0d\u4ec5\u53ef\u4ee5\u7528\u6765\u6253\u5f00Python\uff0c\u8fd8\u53ef\u4ee5\u4f5c\u4e3aPython\u5f00\u53d1\u7684\u91cd\u8981\u5de5\u5177\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5728CMD\u4e2d\u8fdb\u884cPython\u5f00\u53d1\u7684\u6280\u5de7\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5Python\u5305<\/strong>\uff1a\u4f7f\u7528pip\u547d\u4ee4\u53ef\u4ee5\u5728CMD\u4e2d\u5b89\u88c5Python\u5305\u3002\u4f8b\u5982\uff0c\u8f93\u5165\u201cpip install requests\u201d\u53ef\u4ee5\u5b89\u88c5requests\u5e93\u3002\u786e\u4fdd\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165\u547d\u4ee4\u524d\u5df2\u7ecf\u6fc0\u6d3b\u4e86\u6240\u9700\u7684\u865a\u62df\u73af\u5883\uff0c\u4ee5\u907f\u514d\u5f71\u54cd\u5168\u5c40\u73af\u5883\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8c03\u8bd5Python\u4ee3\u7801<\/strong>\uff1a\u5728CMD\u4e2d\u8fd0\u884cPython\u811a\u672c\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528\u8c03\u8bd5\u9009\u9879\u6765\u5e2e\u52a9\u67e5\u627e\u4ee3\u7801\u4e2d\u7684\u95ee\u9898\u3002\u4f8b\u5982\uff0c\u4f7f\u7528\u201cpython -m pdb script.py\u201d\u53ef\u4ee5\u5728\u4ea4\u4e92\u6a21\u5f0f\u4e0b\u8fd0\u884c\u811a\u672c\uff0c\u65b9\u4fbf\u8c03\u8bd5\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7ba1\u7406Python\u9879\u76ee<\/strong>\uff1a\u5728CMD\u4e2d\u4f7f\u7528git\u547d\u4ee4\u53ef\u4ee5\u65b9\u4fbf\u5730\u7ba1\u7406Python\u9879\u76ee\u7684\u7248\u672c\u63a7\u5236\u3002\u901a\u8fc7git init\u3001git add\u3001git commit\u7b49\u547d\u4ee4\uff0c\u53ef\u4ee5\u8f7b\u677e\u8fdb\u884c\u4ee3\u7801\u63d0\u4ea4\u548c\u7248\u672c\u7ba1\u7406\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528\u4efb\u52a1\u8ba1\u5212\u7a0b\u5e8f<\/strong>\uff1aWindows\u4efb\u52a1\u8ba1\u5212\u7a0b\u5e8f\u5141\u8bb8\u4f60\u5728\u6307\u5b9a\u7684\u65f6\u95f4\u81ea\u52a8\u8fd0\u884cPython\u811a\u672c\u3002\u5728\u4efb\u52a1\u8ba1\u5212\u7a0b\u5e8f\u4e2d\uff0c\u4f60\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u4efb\u52a1\uff0c\u5e76\u5c06Python\u811a\u672c\u7684\u8def\u5f84\u8bbe\u7f6e\u4e3a\u4efb\u52a1\u7684\u52a8\u4f5c\uff0c\u4ece\u800c\u5b9e\u73b0\u81ea\u52a8\u5316\u4efb\u52a1\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e03\u3001\u603b\u7ed3\u4e0e\u5efa\u8bae<\/p>\n<\/p>\n<p><p>\u901a\u8fc7CMD\u6253\u5f00\u548c\u8fd0\u884cPython\u662f\u6bcf\u4e2aPython\u5f00\u53d1\u8005\u9700\u8981\u638c\u63e1\u7684\u57fa\u672c\u6280\u80fd\u3002\u638c\u63e1\u547d\u4ee4\u63d0\u793a\u7b26\u7684\u4f7f\u7528\u65b9\u6cd5\uff0c\u4e0d\u4ec5\u80fd\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\uff0c\u8fd8\u80fd\u5728<a href=\"https:\/\/docs.pingcode.com\/blog\/project-management\/23316.html\" target=\"_blank\">\u9879\u76ee\u7ba1\u7406<\/a>\u548c\u81ea\u52a8\u5316\u4efb\u52a1\u4e2d\u53d1\u6325\u91cd\u8981\u4f5c\u7528\u3002<\/p>\n<\/p>\n<p><p>\u5728\u4f7f\u7528CMD\u8fdb\u884cPython\u5f00\u53d1\u65f6\uff0c\u5efa\u8bae\u517b\u6210\u826f\u597d\u7684\u4ee3\u7801\u7ec4\u7ec7\u4e60\u60ef\uff0c\u5408\u7406\u4f7f\u7528\u865a\u62df\u73af\u5883\u7ba1\u7406\u9879\u76ee\u4f9d\u8d56\u3002\u5b9a\u671f\u66f4\u65b0Python\u548c\u6240\u9700\u7684\u5e93\uff0c\u786e\u4fdd\u4f60\u7684\u5f00\u53d1\u73af\u5883\u59cb\u7ec8\u5904\u4e8e\u6700\u4f73\u72b6\u6001\u3002<\/p>\n<\/p>\n<p><p>\u6b64\u5916\uff0c\u5c3d\u7ba1CMD\u662fWindows\u7cfb\u7edf\u4e2d\u9ed8\u8ba4\u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u4f46\u4f60\u4e5f\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u5176\u4ed6\u66f4\u4e3a\u5f3a\u5927\u7684\u547d\u4ee4\u884c\u66ff\u4ee3\u5de5\u5177\uff0c\u5982Windows Terminal\u3001Cmder\u6216PowerShell\u7b49\uff0c\u8fd9\u4e9b\u5de5\u5177\u63d0\u4f9b\u4e86\u66f4\u4e30\u5bcc\u7684\u529f\u80fd\u548c\u66f4\u597d\u7684\u7528\u6237\u4f53\u9a8c\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Windows\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u68c0\u67e5Python\u662f\u5426\u5df2\u5b89\u88c5\uff1f<\/strong><br \/>\u8981\u786e\u8ba4Python\u662f\u5426\u5df2\u5728\u60a8\u7684\u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5\uff0c\u60a8\u53ef\u4ee5\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff08CMD\uff09\uff0c\u7136\u540e\u8f93\u5165<code>python --version<\/code>\u6216<code>python -V<\/code>\u3002\u5982\u679c\u6210\u529f\u5b89\u88c5\uff0c\u7cfb\u7edf\u4f1a\u663e\u793a\u5df2\u5b89\u88c5\u7684Python\u7248\u672c\u53f7\u3002\u5982\u679c\u7cfb\u7edf\u63d0\u793a\u201c\u672a\u627e\u5230\u547d\u4ee4\u201d\u6216\u7c7b\u4f3c\u4fe1\u606f\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u5b89\u88c5Python\u6216\u5c06\u5176\u6dfb\u52a0\u5230\u7cfb\u7edf\u8def\u5f84\u4e2d\u3002<\/p>\n<p><strong>\u5982\u679cCMD\u4e2d\u65e0\u6cd5\u8bc6\u522bPython\u547d\u4ee4\uff0c\u6211\u8be5\u600e\u4e48\u529e\uff1f<\/strong><br \/>\u5982\u679c\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165<code>python<\/code>\u540e\u7cfb\u7edf\u65e0\u6cd5\u8bc6\u522b\uff0c\u60a8\u53ef\u4ee5\u68c0\u67e5Python\u7684\u5b89\u88c5\u8def\u5f84\u662f\u5426\u5df2\u6dfb\u52a0\u5230\u7cfb\u7edf\u7684\u73af\u5883\u53d8\u91cf\u4e2d\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7\u53f3\u952e\u70b9\u51fb\u201c\u6b64\u7535\u8111\u201d\u6216\u201c\u6211\u7684\u7535\u8111\u201d\uff0c\u9009\u62e9\u201c\u5c5e\u6027\u201d\uff0c\u7136\u540e\u70b9\u51fb\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d\uff0c\u8fdb\u5165\u201c\u73af\u5883\u53d8\u91cf\u201d\u8fdb\u884c\u68c0\u67e5\u548c\u4fee\u6539\u3002<\/p>\n<p><strong>\u4f7f\u7528CMD\u8fd0\u884cPython\u811a\u672c\u7684\u6b65\u9aa4\u662f\u4ec0\u4e48\uff1f<\/strong><br \/>\u8981\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8fd0\u884cPython\u811a\u672c\uff0c\u9996\u5148\u9700\u8981\u5bfc\u822a\u5230\u5305\u542b\u811a\u672c\u7684\u76ee\u5f55\u3002\u53ef\u4ee5\u4f7f\u7528<code>cd<\/code>\u547d\u4ee4\u6765\u66f4\u6539\u76ee\u5f55\uff0c\u4f8b\u5982<code>cd C:\\path\\to\\your\\script<\/code>\u3002\u7136\u540e\uff0c\u8f93\u5165<code>python script_name.py<\/code>\u6765\u6267\u884c\u60a8\u7684Python\u811a\u672c\uff0c\u786e\u4fdd\u5c06<code>script_name.py<\/code>\u66ff\u6362\u4e3a\u60a8\u7684\u5b9e\u9645\u6587\u4ef6\u540d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Windows\u64cd\u4f5c\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u63d0\u793a\u7b26\uff08CMD\uff09\u6253\u5f00Python\u3002\u9996\u5148\uff0c\u786e\u4fdd\u4f60\u7684\u8ba1\u7b97\u673a\u4e0a\u5df2\u7ecf\u5b89\u88c5\u4e86Py [&hellip;]","protected":false},"author":3,"featured_media":922163,"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\/922162"}],"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=922162"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/922162\/revisions"}],"predecessor-version":[{"id":922164,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/922162\/revisions\/922164"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/922163"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=922162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=922162"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=922162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}