{"id":952379,"date":"2024-12-27T01:29:14","date_gmt":"2024-12-26T17:29:14","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/952379.html"},"modified":"2024-12-27T01:29:15","modified_gmt":"2024-12-26T17:29:15","slug":"%e5%a6%82%e4%bd%95cmd%e6%89%93%e5%bc%80python","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/952379.html","title":{"rendered":"\u5982\u4f55cmd\u6253\u5f00python"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25090246\/8817d6ba-4d3b-4c69-a45e-df66792f72e0.webp\" alt=\"\u5982\u4f55cmd\u6253\u5f00python\" \/><\/p>\n<p><p> <strong>\u5728Windows\u64cd\u4f5c\u7cfb\u7edf\u4e2d\uff0c\u901a\u8fc7\u547d\u4ee4\u63d0\u793a\u7b26\uff08cmd\uff09\u6253\u5f00Python\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u786e\u4fddPython\u5df2\u6b63\u786e\u5b89\u88c5\u3001\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165\u6b63\u786e\u7684\u547d\u4ee4\u3001\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u3002<\/strong>\u5176\u4e2d\uff0c\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\u662f\u786e\u4fdd\u5728\u4efb\u4f55\u76ee\u5f55\u4e0b\u90fd\u80fd\u76f4\u63a5\u901a\u8fc7\u547d\u4ee4\u63d0\u793a\u7b26\u542f\u52a8Python\u7684\u5173\u952e\u6b65\u9aa4\u3002\u63a5\u4e0b\u6765\uff0c\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u8fdb\u884c\u8fd9\u4e9b\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u786e\u4fddPython\u5df2\u6b63\u786e\u5b89\u88c5<\/p>\n<\/p>\n<p><p>\u5728\u4f7f\u7528\u547d\u4ee4\u63d0\u793a\u7b26\u6253\u5f00Python\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u786e\u4fddPython\u5df2\u7ecf\u6b63\u786e\u5b89\u88c5\u5728\u4f60\u7684\u8ba1\u7b97\u673a\u4e0a\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p>\u4e0b\u8f7dPython\uff1a\u8bbf\u95eePython\u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/www.python.org\/%EF%BC%89%EF%BC%8C%E9%80%89%E6%8B%A9%E9%80%82%E5%90%88%E4%BD%A0%E7%B3%BB%E7%BB%9F%E7%9A%84Python%E7%89%88%E6%9C%AC%E8%BF%9B%E8%A1%8C%E4%B8%8B%E8%BD%BD%E3%80%82%E9%80%9A%E5%B8%B8%E5%BB%BA%E8%AE%AE%E9%80%89%E6%8B%A9%E6%9C%80%E6%96%B0%E7%9A%84%E7%A8%B3%E5%AE%9A%E7%89%88%E6%9C%AC%E3%80%82\">https:\/\/www.python.org\/\uff09\uff0c\u9009\u62e9\u9002\u5408\u4f60\u7cfb\u7edf\u7684Python\u7248\u672c\u8fdb\u884c\u4e0b\u8f7d\u3002\u901a\u5e38\u5efa\u8bae\u9009\u62e9\u6700\u65b0\u7684\u7a33\u5b9a\u7248\u672c\u3002<\/a><\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u5b89\u88c5Python\uff1a\u8fd0\u884c\u4e0b\u8f7d\u7684\u5b89\u88c5\u7a0b\u5e8f\u3002\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u52a1\u5fc5\u52fe\u9009\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u8fd9\u5c06\u81ea\u52a8\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u65b9\u4fbf\u540e\u7eed\u4f7f\u7528\u547d\u4ee4\u63d0\u793a\u7b26\u8fd0\u884cPython\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u9a8c\u8bc1\u5b89\u88c5\uff1a\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u8f93\u5165<code>python --version<\/code>\uff0c\u67e5\u770b\u662f\u5426\u663e\u793aPython\u7248\u672c\u4fe1\u606f\u3002\u5982\u679c\u663e\u793a\u7248\u672c\u4fe1\u606f\uff0c\u8bf4\u660ePython\u5df2\u6b63\u786e\u5b89\u88c5\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165\u6b63\u786e\u7684\u547d\u4ee4<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u547d\u4ee4\u63d0\u793a\u7b26\u76f4\u63a5\u542f\u52a8Python\u7684\u65b9\u6cd5\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u8f93\u5165\u6b63\u786e\u7684\u547d\u4ee4\u5373\u53ef\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p>\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff1a\u53ef\u4ee5\u901a\u8fc7\u201c\u5f00\u59cb\u201d\u83dc\u5355\u641c\u7d22\u201ccmd\u201d\uff0c\u6216\u4f7f\u7528\u5feb\u6377\u952eWin + R\u6253\u5f00\u8fd0\u884c\u7a97\u53e3\uff0c\u8f93\u5165\u201ccmd\u201d\u5e76\u56de\u8f66\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u8f93\u5165Python\u547d\u4ee4\uff1a\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165<code>python<\/code>\u6216<code>py<\/code>\uff08\u5177\u4f53\u53d6\u51b3\u4e8e\u5b89\u88c5\u65f6\u7684\u8bbe\u7f6e\uff09\uff0c\u7136\u540e\u6309\u56de\u8f66\u3002\u5982\u679c\u73af\u5883\u53d8\u91cf\u5df2\u6b63\u786e\u914d\u7f6e\uff0cPython\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\u5c06\u542f\u52a8\uff0c\u4f60\u53ef\u4ee5\u5728\u8fd9\u91cc\u8f93\u5165Python\u4ee3\u7801\u8fdb\u884c\u6d4b\u8bd5\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u9000\u51faPython\u89e3\u91ca\u5668\uff1a\u5728Python\u89e3\u91ca\u5668\u4e2d\uff0c\u8f93\u5165<code>exit()<\/code>\u6216\u4f7f\u7528\u5feb\u6377\u952eCtrl + Z\uff08\u7136\u540e\u6309\u56de\u8f66\uff09\u9000\u51fa\u89e3\u91ca\u5668\uff0c\u8fd4\u56de\u547d\u4ee4\u63d0\u793a\u7b26\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<\/p>\n<\/p>\n<p><p>\u5982\u679c\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165<code>python<\/code>\u547d\u4ee4\u65f6\u63d0\u793a\u627e\u4e0d\u5230\u547d\u4ee4\uff0c\u53ef\u80fd\u662f\u56e0\u4e3a\u73af\u5883\u53d8\u91cf\u672a\u6b63\u786e\u914d\u7f6e\u3002\u53ef\u4ee5\u624b\u52a8\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u4ee5\u786e\u4fdd\u5728\u4efb\u4f55\u76ee\u5f55\u4e0b\u90fd\u80fd\u542f\u52a8Python\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p>\u6253\u5f00\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u8bbe\u7f6e\uff1a\u53f3\u952e\u5355\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\u5728\u201c\u7cfb\u7edf\u5c5e\u6027\u201d\u7a97\u53e3\u4e2d\u9009\u62e9\u201c\u73af\u5883\u53d8\u91cf\u201d\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u7f16\u8f91Path\u53d8\u91cf\uff1a\u5728\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u90e8\u5206\u627e\u5230\u5e76\u9009\u62e9\u201cPath\u201d\u53d8\u91cf\uff0c\u70b9\u51fb\u201c\u7f16\u8f91\u201d\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u6dfb\u52a0Python\u8def\u5f84\uff1a\u70b9\u51fb\u201c\u65b0\u5efa\u201d\uff0c\u5c06Python\u7684\u5b89\u88c5\u8def\u5f84\uff08\u4f8b\u5982\uff1aC:\\Python39\\\uff0c\u5177\u4f53\u8def\u5f84\u6839\u636e\u4f60\u7684\u5b89\u88c5\u4f4d\u7f6e\u800c\u5b9a\uff09\u548cPython\u811a\u672c\u8def\u5f84\uff08\u4f8b\u5982\uff1aC:\\Python39\\Scripts\\\uff09\u6dfb\u52a0\u5230Path\u53d8\u91cf\u4e2d\uff0c\u7136\u540e\u70b9\u51fb\u201c\u786e\u5b9a\u201d\u4fdd\u5b58\u66f4\u6539\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u9a8c\u8bc1\u914d\u7f6e\uff1a\u91cd\u65b0\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u8f93\u5165<code>python --version<\/code>\u67e5\u770b\u662f\u5426\u80fd\u6b63\u786e\u663e\u793aPython\u7248\u672c\u4fe1\u606f\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u5e94\u8be5\u80fd\u591f\u987a\u5229\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u6253\u5f00Python\u5e76\u8fdb\u884c\u7f16\u7a0b\u3002\u786e\u4fdd\u73af\u5883\u53d8\u91cf\u8bbe\u7f6e\u6b63\u786e\u662f\u5173\u952e\uff0c\u8fd9\u6837\u53ef\u4ee5\u907f\u514d\u5728\u4e0d\u540c\u76ee\u5f55\u4e0b\u4f7f\u7528Python\u65f6\u9047\u5230\u7684\u8def\u5f84\u95ee\u9898\u3002\u5e0c\u671b\u8fd9\u4e9b\u4fe1\u606f\u80fd\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u4f7f\u7528Python\u8fdb\u884c\u5f00\u53d1\u548c\u5b66\u4e60\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u68c0\u67e5Python\u662f\u5426\u5df2\u5b89\u88c5\uff1f<\/strong><br \/>\u8981\u786e\u8ba4Python\u662f\u5426\u5df2\u5b89\u88c5\u5728\u60a8\u7684\u7cfb\u7edf\u4e0a\uff0c\u53ef\u4ee5\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff08CMD\uff09\uff0c\u8f93\u5165<code>python --version<\/code>\u6216<code>python -V<\/code>\uff0c\u7136\u540e\u6309\u56de\u8f66\u3002\u5982\u679cPython\u5df2\u6b63\u786e\u5b89\u88c5\uff0c\u60a8\u5c06\u770b\u5230\u5176\u7248\u672c\u53f7\u3002\u5982\u679c\u672a\u5b89\u88c5\uff0c\u7cfb\u7edf\u5c06\u63d0\u793a\u60a8\u76f8\u5173\u4fe1\u606f\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u4e0b\u8f7d\u5e76\u5b89\u88c5Python\u3002<\/p>\n<p><strong>\u5728CMD\u4e2d\u6253\u5f00Python\u7684\u4ea4\u4e92\u5f0f\u6a21\u5f0f\u7684\u6b65\u9aa4\u662f\u4ec0\u4e48\uff1f<\/strong><br \/>\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\uff0c\u8f93\u5165<code>python<\/code>\u5e76\u6309\u56de\u8f66\u952e\uff0c\u5373\u53ef\u8fdb\u5165Python\u7684\u4ea4\u4e92\u5f0f\u6a21\u5f0f\u3002\u5728\u6b64\u6a21\u5f0f\u4e0b\uff0c\u60a8\u53ef\u4ee5\u76f4\u63a5\u8f93\u5165Python\u4ee3\u7801\u5e76\u7acb\u5373\u770b\u5230\u7ed3\u679c\u3002\u8fd9\u662f\u6d4b\u8bd5\u4ee3\u7801\u7247\u6bb5\u6216\u5feb\u901f\u8ba1\u7b97\u7684\u7406\u60f3\u73af\u5883\u3002<\/p>\n<p><strong>\u5982\u4f55\u901a\u8fc7CMD\u8fd0\u884cPython\u811a\u672c\uff1f<\/strong><br \/>\u82e5\u8981\u8fd0\u884cPython\u811a\u672c\uff0c\u9700\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u5bfc\u822a\u5230\u811a\u672c\u6240\u5728\u7684\u76ee\u5f55\u3002\u4f7f\u7528<code>cd<\/code>\u547d\u4ee4\u66f4\u6539\u76ee\u5f55\u540e\uff0c\u8f93\u5165<code>python script_name.py<\/code>\uff08\u5c06<code>script_name.py<\/code>\u66ff\u6362\u4e3a\u60a8\u7684\u811a\u672c\u6587\u4ef6\u540d\uff09\uff0c\u6309\u56de\u8f66\u5373\u53ef\u6267\u884c\u8be5\u811a\u672c\u3002\u786e\u4fddPython\u811a\u672c\u7684\u8def\u5f84\u548c\u540d\u79f0\u90fd\u6b63\u786e\uff0c\u4ee5\u907f\u514d\u8fd0\u884c\u9519\u8bef\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Windows\u64cd\u4f5c\u7cfb\u7edf\u4e2d\uff0c\u901a\u8fc7\u547d\u4ee4\u63d0\u793a\u7b26\uff08cmd\uff09\u6253\u5f00Python\u7684\u65b9\u6cd5\u5305\u62ec\uff1a\u786e\u4fddPython\u5df2\u6b63\u786e\u5b89\u88c5\u3001\u5728 [&hellip;]","protected":false},"author":3,"featured_media":952383,"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\/952379"}],"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=952379"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/952379\/revisions"}],"predecessor-version":[{"id":952384,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/952379\/revisions\/952384"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/952383"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=952379"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=952379"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=952379"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}