{"id":946825,"date":"2024-12-26T23:46:05","date_gmt":"2024-12-26T15:46:05","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/946825.html"},"modified":"2024-12-26T23:46:08","modified_gmt":"2024-12-26T15:46:08","slug":"windows%e5%a6%82%e4%bd%95%e6%89%93%e5%bc%80python","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/946825.html","title":{"rendered":"windows\u5982\u4f55\u6253\u5f00python"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25082843\/7a1bbc37-2ef9-4acc-b5b3-edc9b483fa5d.webp\" alt=\"windows\u5982\u4f55\u6253\u5f00python\" \/><\/p>\n<p><p> <strong>\u5728Windows\u4e0a\u6253\u5f00Python\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5305\u62ec\u4f7f\u7528\u547d\u4ee4\u63d0\u793a\u7b26\u3001\u901a\u8fc7Python IDLE\u3001\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u4ee5\u53ca\u5728Windows PowerShell\u4e2d\u8fd0\u884cPython\u3002\u4e3a\u4e86\u5e2e\u52a9\u60a8\u66f4\u597d\u5730\u7406\u89e3\u548c\u64cd\u4f5c\uff0c\u4ee5\u4e0b\u662f\u8be6\u7ec6\u6b65\u9aa4\u548c\u4e00\u4e9b\u5c0f\u6280\u5de7\uff1a<\/strong><\/p>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u6211\u4eec\u6765\u8be6\u7ec6\u5c55\u5f00\u5176\u4e2d\u4e00\u79cd\u65b9\u6cd5\u2014\u2014<strong>\u4f7f\u7528\u547d\u4ee4\u63d0\u793a\u7b26\u6253\u5f00Python<\/strong>\u3002\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u547d\u4ee4\u63d0\u793a\u7b26\u662f\u4e00\u4e2a\u975e\u5e38\u6709\u6548\u7684\u5de5\u5177\u3002\u8981\u901a\u8fc7\u5b83\u6253\u5f00Python\uff0c\u60a8\u9700\u8981\u786e\u4fddPython\u5df2\u7ecf\u6b63\u786e\u5b89\u88c5\u5e76\u4e14\u8def\u5f84\u5df2\u6dfb\u52a0\u5230\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u4e2d\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6309\u4e0b<code>Win + R<\/code>\u952e\uff0c\u8f93\u5165<code>cmd<\/code>\uff0c\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u7a97\u53e3\u3002\u5728\u7a97\u53e3\u4e2d\uff0c\u8f93\u5165<code>python<\/code>\uff0c\u6309\u4e0b\u56de\u8f66\u952e\u3002\u5982\u679c\u914d\u7f6e\u6b63\u786e\uff0c\u60a8\u5c06\u770b\u5230Python\u89e3\u91ca\u5668\u7684\u7248\u672c\u4fe1\u606f\uff0c\u5e76\u8fdb\u5165Python\u4ea4\u4e92\u5f0f\u6a21\u5f0f\u3002\u5728\u8fd9\u4e2a\u6a21\u5f0f\u4e0b\uff0c\u60a8\u53ef\u4ee5\u8f93\u5165Python\u4ee3\u7801\u5e76\u7acb\u5373\u770b\u5230\u7ed3\u679c\uff0c\u8fd9\u662f\u5b66\u4e60\u548c\u6d4b\u8bd5Python\u4ee3\u7801\u7684\u4e00\u4e2a\u975e\u5e38\u65b9\u4fbf\u7684\u65b9\u5f0f\u3002<\/p>\n<\/p>\n<hr>\n<p><h2>\u4e00\u3001\u4f7f\u7528\u547d\u4ee4\u63d0\u793a\u7b26\u6253\u5f00Python<\/h2>\n<\/p>\n<p><p><strong>1. \u5b89\u88c5Python\u5e76\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/strong><\/p>\n<\/p>\n<p><p>\u5728Windows\u4e0a\u5b89\u88c5Python\u7684\u7b2c\u4e00\u6b65\u662f\u4ecePython\u7684\u5b98\u65b9\u7f51\u7ad9\uff08python.org\uff09\u4e0b\u8f7d\u9002\u5408\u60a8\u7cfb\u7edf\u7684Python\u5b89\u88c5\u7a0b\u5e8f\u3002\u901a\u5e38\uff0c\u60a8\u53ef\u4ee5\u9009\u62e9\u6700\u65b0\u7684\u7a33\u5b9a\u7248\u672c\u3002\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u786e\u4fdd\u52fe\u9009\u201cAdd Python to PATH\u201d\u9009\u9879\u3002\u8fd9\u4f1a\u81ea\u52a8\u5c06Python\u53ef\u6267\u884c\u6587\u4ef6\u6dfb\u52a0\u5230\u7cfb\u7edf\u7684PATH\u73af\u5883\u53d8\u91cf\u4e2d\uff0c\u4ece\u800c\u5141\u8bb8\u60a8\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u76f4\u63a5\u8bbf\u95eePython\u3002<\/p>\n<\/p>\n<p><p><strong>2. \u9a8c\u8bc1Python\u5b89\u88c5<\/strong><\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6309\u4e0b<code>Win + R<\/code>\u952e\uff0c\u8f93\u5165<code>cmd<\/code>\uff0c\u7136\u540e\u6309\u4e0b\u56de\u8f66\u952e\u4ee5\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u3002\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165<code>python --version<\/code>\u6216<code>python<\/code>\uff0c\u7136\u540e\u6309\u4e0b\u56de\u8f66\u952e\u3002\u5982\u679cPython\u5b89\u88c5\u6b63\u786e\uff0c\u60a8\u5c06\u770b\u5230Python\u7684\u7248\u672c\u4fe1\u606f\u3002\u5982\u679c\u6ca1\u6709\u770b\u5230\u7248\u672c\u4fe1\u606f\uff0c\u5219\u53ef\u80fd\u9700\u8981\u624b\u52a8\u5c06Python\u7684\u5b89\u88c5\u8def\u5f84\u6dfb\u52a0\u5230\u7cfb\u7edf\u7684PATH\u73af\u5883\u53d8\u91cf\u4e2d\u3002<\/p>\n<\/p>\n<p><h2>\u4e8c\u3001\u901a\u8fc7Python IDLE\u6253\u5f00Python<\/h2>\n<\/p>\n<p><p><strong>1. \u4f7f\u7528Python IDLE<\/strong><\/p>\n<\/p>\n<p><p>Python IDLE\u662fPython\u81ea\u5e26\u7684\u4e00\u4e2a\u7b80\u5355\u800c\u6709\u6548\u7684\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u3002\u5b89\u88c5Python\u65f6\uff0cIDLE\u901a\u5e38\u4f1a\u4e00\u540c\u5b89\u88c5\u3002\u60a8\u53ef\u4ee5\u901a\u8fc7Windows\u5f00\u59cb\u83dc\u5355\u641c\u7d22\u201cIDLE\u201d\u6765\u6253\u5f00\u3002\u6253\u5f00IDLE\u540e\uff0c\u60a8\u4f1a\u770b\u5230\u4e00\u4e2a\u4ea4\u4e92\u5f0f\u7684Python Shell\uff0c\u7c7b\u4f3c\u4e8e\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u4f46\u66f4\u52a0\u9002\u5408\u4e8e\u4e66\u5199\u548c\u6d4b\u8bd5Python\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><p><strong>2. \u5728IDLE\u4e2d\u7f16\u5199\u548c\u8fd0\u884cPython\u4ee3\u7801<\/strong><\/p>\n<\/p>\n<p><p>IDLE\u63d0\u4f9b\u4e86\u4e00\u4e2a\u56fe\u5f62\u7528\u6237\u754c\u9762\uff0c\u60a8\u53ef\u4ee5\u5728\u5176\u4e2d\u7f16\u5199\u548c\u8fd0\u884cPython\u4ee3\u7801\u3002\u8981\u521b\u5efa\u65b0\u6587\u4ef6\uff0c\u70b9\u51fb\u201cFile\u201d\u83dc\u5355\u5e76\u9009\u62e9\u201cNew File\u201d\uff0c\u8fd9\u5c06\u6253\u5f00\u4e00\u4e2a\u65b0\u7684\u7f16\u8f91\u7a97\u53e3\u3002\u5728\u7f16\u8f91\u7a97\u53e3\u4e2d\uff0c\u60a8\u53ef\u4ee5\u7f16\u5199Python\u811a\u672c\uff0c\u5e76\u901a\u8fc7\u70b9\u51fb\u201cRun\u201d\u83dc\u5355\u4e2d\u7684\u201cRun Module\u201d\u9009\u9879\uff08\u6216\u6309\u4e0bF5\u952e\uff09\u6765\u8fd0\u884c\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><h2>\u4e09\u3001\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09<\/h2>\n<\/p>\n<p><p><strong>1. \u9009\u62e9\u9002\u5408\u7684IDE<\/strong><\/p>\n<\/p>\n<p><p>\u6709\u8bb8\u591a\u529f\u80fd\u5f3a\u5927\u7684IDE\u53ef\u4ee5\u7528\u4e8ePython\u5f00\u53d1\uff0c\u5176\u4e2d\u5305\u62ecPyCharm\u3001Visual Studio Code\u3001Eclipse\uff08\u914d\u5408PyDev\u63d2\u4ef6\uff09\u7b49\u3002\u8fd9\u4e9bIDE\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u529f\u80fd\uff0c\u5982\u4ee3\u7801\u81ea\u52a8\u8865\u5168\u3001\u8c03\u8bd5\u5de5\u5177\u3001\u7248\u672c\u63a7\u5236\u96c6\u6210\u7b49\uff0c\u6709\u52a9\u4e8e\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u3002<\/p>\n<\/p>\n<p><p><strong>2. \u914d\u7f6e\u548c\u4f7f\u7528IDE<\/strong><\/p>\n<\/p>\n<p><p>\u4ee5PyCharm\u4e3a\u4f8b\uff0c\u5b89\u88c5\u540e\u9996\u6b21\u542f\u52a8\u65f6\uff0c\u9700\u8981\u914d\u7f6ePython\u89e3\u91ca\u5668\u3002PyCharm\u4f1a\u81ea\u52a8\u68c0\u6d4b\u7cfb\u7edf\u4e0a\u7684Python\u5b89\u88c5\uff0c\u5e76\u63d0\u793a\u60a8\u9009\u62e9\u3002\u5b8c\u6210\u914d\u7f6e\u540e\uff0c\u60a8\u53ef\u4ee5\u521b\u5efa\u65b0\u7684Python\u9879\u76ee\uff0c\u5e76\u5728\u9879\u76ee\u4e2d\u7f16\u5199\u3001\u8fd0\u884c\u548c\u8c03\u8bd5Python\u4ee3\u7801\u3002PyCharm\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u4ee3\u7801\u7f16\u8f91\u529f\u80fd\u548c\u8c03\u8bd5\u5de5\u5177\uff0c\u53ef\u4ee5\u6781\u5927\u5730\u63d0\u5347\u60a8\u7684\u5f00\u53d1\u4f53\u9a8c\u3002<\/p>\n<\/p>\n<p><h2>\u56db\u3001\u5728Windows PowerShell\u4e2d\u8fd0\u884cPython<\/h2>\n<\/p>\n<p><p><strong>1. \u4f7f\u7528Windows PowerShell<\/strong><\/p>\n<\/p>\n<p><p>Windows PowerShell\u662fWindows\u4e0a\u7684\u4e00\u4e2a\u547d\u4ee4\u884c\u5916\u58f3\uff0c\u529f\u80fd\u5f3a\u5927\u4e14\u7075\u6d3b\u3002\u4e0e\u547d\u4ee4\u63d0\u793a\u7b26\u7c7b\u4f3c\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7PowerShell\u8fd0\u884cPython\u4ee3\u7801\u3002\u8981\u6253\u5f00PowerShell\uff0c\u6309\u4e0b<code>Win + X<\/code>\u952e\uff0c\u7136\u540e\u9009\u62e9\u201cWindows PowerShell\u201d\u3002<\/p>\n<\/p>\n<p><p><strong>2. \u5728PowerShell\u4e2d\u8fd0\u884cPython\u4ee3\u7801<\/strong><\/p>\n<\/p>\n<p><p>\u5728PowerShell\u7a97\u53e3\u4e2d\uff0c\u8f93\u5165<code>python<\/code>\u5e76\u6309\u4e0b\u56de\u8f66\u952e\uff0c\u8fdb\u5165Python\u4ea4\u4e92\u5f0f\u6a21\u5f0f\u3002\u5728\u8fd9\u91cc\uff0c\u60a8\u53ef\u4ee5\u8f93\u5165Python\u4ee3\u7801\u5e76\u7acb\u5373\u6267\u884c\u3002PowerShell\u8fd8\u652f\u6301\u8fd0\u884cPython\u811a\u672c\u6587\u4ef6\uff0c\u60a8\u53ea\u9700\u8f93\u5165<code>python script.py<\/code>\uff0c\u5176\u4e2d<code>script.py<\/code>\u662f\u60a8\u8981\u8fd0\u884c\u7684Python\u811a\u672c\u6587\u4ef6\u7684\u8def\u5f84\u3002<\/p>\n<\/p>\n<hr>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u591a\u79cd\u65b9\u6cd5\uff0c\u60a8\u53ef\u4ee5\u5728Windows\u4e0a\u8f7b\u677e\u6253\u5f00\u5e76\u8fd0\u884cPython\u3002\u6839\u636e\u60a8\u7684\u9700\u6c42\u548c\u5f00\u53d1\u4e60\u60ef\uff0c\u9009\u62e9\u6700\u9002\u5408\u60a8\u7684\u65b9\u6cd5\uff0c\u5e76\u5145\u5206\u5229\u7528Python\u7684\u5f3a\u5927\u529f\u80fd\u8fdb\u884c\u5f00\u53d1\u548c\u5b66\u4e60\u3002\u65e0\u8bba\u662f\u521d\u5b66\u8005\u8fd8\u662f\u7ecf\u9a8c\u4e30\u5bcc\u7684\u5f00\u53d1\u8005\uff0c\u4e86\u89e3\u8fd9\u4e9b\u57fa\u672c\u64cd\u4f5c\u90fd\u975e\u5e38\u91cd\u8981\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Windows\u4e0a\u5b89\u88c5Python\uff1f<\/strong><br \/>\u5728Windows\u4e0a\u5b89\u88c5Python\u76f8\u5bf9\u7b80\u5355\u3002\u60a8\u53ef\u4ee5\u8bbf\u95eePython\u7684\u5b98\u65b9\u7f51\u7ad9\uff08python.org\uff09\uff0c\u4e0b\u8f7d\u9002\u5408\u60a8\u7cfb\u7edf\u7684\u5b89\u88c5\u7a0b\u5e8f\u3002\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u53cc\u51fb\u5b89\u88c5\u5305\uff0c\u786e\u4fdd\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u52fe\u9009\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u8fd9\u6837\u60a8\u5c31\u53ef\u4ee5\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u76f4\u63a5\u8fd0\u884cPython\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165<code>python<\/code>\u6765\u786e\u8ba4\u5b89\u88c5\u662f\u5426\u6210\u529f\u3002<\/p>\n<p><strong>\u5728Windows\u4e0a\u4f7f\u7528\u547d\u4ee4\u884c\u6253\u5f00Python\u7684\u6b65\u9aa4\u662f\u4ec0\u4e48\uff1f<\/strong><br \/>\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\u53ef\u4ee5\u901a\u8fc7\u641c\u7d22\u201ccmd\u201d\u6216\u201c\u547d\u4ee4\u63d0\u793a\u7b26\u201d\u6765\u5b8c\u6210\u3002\u542f\u52a8\u540e\uff0c\u8f93\u5165<code>python<\/code>\u5e76\u6309\u4e0b\u56de\u8f66\u952e\uff0c\u5982\u679c\u5b89\u88c5\u6b63\u786e\uff0c\u60a8\u5c06\u770b\u5230Python\u7684\u7248\u672c\u4fe1\u606f\u4ee5\u53ca\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\u7684\u63d0\u793a\u7b26\u3002\u5728\u8fd9\u91cc\uff0c\u60a8\u53ef\u4ee5\u76f4\u63a5\u8f93\u5165Python\u4ee3\u7801\u5e76\u6267\u884c\u3002<\/p>\n<p><strong>\u662f\u5426\u53ef\u4ee5\u5728Windows\u4e0a\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u6765\u8fd0\u884cPython\uff1f<\/strong><br \/>\u5f53\u7136\u53ef\u4ee5\uff01\u5728Windows\u4e0a\uff0c\u6709\u8bb8\u591a\u6d41\u884c\u7684IDE\u53ef\u4ee5\u7528\u6765\u7f16\u5199\u548c\u8fd0\u884cPython\u4ee3\u7801\uff0c\u6bd4\u5982PyCharm\u3001Visual Studio Code\u548cJupyter Notebook\u7b49\u3002\u4e0b\u8f7d\u5e76\u5b89\u88c5\u60a8\u9009\u62e9\u7684IDE\u540e\uff0c\u60a8\u53ef\u4ee5\u521b\u5efa\u65b0\u7684Python\u6587\u4ef6\uff0c\u7f16\u5199\u4ee3\u7801\u5e76\u901a\u8fc7IDE\u7684\u8fd0\u884c\u6309\u94ae\u76f4\u63a5\u6267\u884c\u4ee3\u7801\uff0c\u8fd9\u6837\u4e0d\u4ec5\u63d0\u9ad8\u4e86\u5f00\u53d1\u6548\u7387\uff0c\u8fd8\u80fd\u66f4\u597d\u5730\u7ba1\u7406\u9879\u76ee\u548c\u8c03\u8bd5\u4ee3\u7801\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Windows\u4e0a\u6253\u5f00Python\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5305\u62ec\u4f7f\u7528\u547d\u4ee4\u63d0\u793a\u7b26\u3001\u901a\u8fc7Python IDLE\u3001\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af [&hellip;]","protected":false},"author":3,"featured_media":946832,"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\/946825"}],"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=946825"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/946825\/revisions"}],"predecessor-version":[{"id":946835,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/946825\/revisions\/946835"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/946832"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=946825"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=946825"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=946825"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}