{"id":931345,"date":"2024-12-26T17:34:45","date_gmt":"2024-12-26T09:34:45","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/931345.html"},"modified":"2024-12-26T17:34:47","modified_gmt":"2024-12-26T09:34:47","slug":"python-pc%e5%a6%82%e4%bd%95%e6%89%93%e5%bc%80","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/931345.html","title":{"rendered":"python pc\u5982\u4f55\u6253\u5f00"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25065657\/4b99d4f9-2f73-4531-9cb9-9c48301b6dce.webp\" alt=\"python pc\u5982\u4f55\u6253\u5f00\" \/><\/p>\n<p><p> <strong>\u8981\u5728PC\u4e0a\u6253\u5f00Python\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u5b89\u88c5Python\u89e3\u91ca\u5668\u3001\u4f7f\u7528Python IDE\u3001\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e0b\u8fd0\u884cPython\u811a\u672c\u7b49\u65b9\u5f0f\u5b9e\u73b0<\/strong>\u3002\u5176\u4e2d\uff0c\u5b89\u88c5Python\u89e3\u91ca\u5668\u662f\u5fc5\u4e0d\u53ef\u5c11\u7684\u6b65\u9aa4\uff0c\u56e0\u4e3a\u5b83\u662f\u8fd0\u884cPython\u4ee3\u7801\u7684\u57fa\u7840\u3002\u4ee5\u4e0b\u662f\u5173\u4e8e\u5982\u4f55\u5728PC\u4e0a\u6253\u5f00\u548c\u8fd0\u884cPython\u7684\u4e00\u4e9b\u8be6\u7ec6\u6b65\u9aa4\u548c\u5efa\u8bae\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u5b89\u88c5Python\u89e3\u91ca\u5668<\/p>\n<\/p>\n<p><p>\u8981\u5728PC\u4e0a\u8fd0\u884cPython\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5Python\u89e3\u91ca\u5668\u3002Python\u7684\u5b98\u65b9\u7f51\u7ad9\u63d0\u4f9b\u4e86\u6700\u65b0\u7248\u672c\u7684Python\u5b89\u88c5\u5305\u3002\u4f60\u53ef\u4ee5\u8bbf\u95ee<a href=\"https:\/\/www.python.org\/\">Python.org<\/a>\u4e0b\u8f7d\u5e76\u5b89\u88c5\u9002\u5408\u4f60\u64cd\u4f5c\u7cfb\u7edf\u7684Python\u7248\u672c\u3002\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u786e\u4fdd\u52fe\u9009\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u4ee5\u4fbf\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u5168\u5c40\u8bbf\u95eePython\u3002<\/p>\n<\/p>\n<p><p>Python\u89e3\u91ca\u5668\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165<code>python<\/code>\u6216<code>python3<\/code>\u6765\u542f\u52a8Python\u4ea4\u4e92\u5f0f\u4f1a\u8bdd\u3002\u5728\u8be5\u4f1a\u8bdd\u4e2d\uff0c\u4f60\u53ef\u4ee5\u76f4\u63a5\u8f93\u5165Python\u547d\u4ee4\u5e76\u67e5\u770b\u8f93\u51fa\u7ed3\u679c\u3002\u8fd9\u79cd\u65b9\u5f0f\u975e\u5e38\u9002\u5408\u7528\u4e8e\u6d4b\u8bd5\u5c0f\u6bb5\u4ee3\u7801\u548c\u8fdb\u884c\u7b80\u5355\u7684\u8ba1\u7b97\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u4f7f\u7528Python IDE<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u9009\u62e9\u5408\u9002\u7684Python IDE<\/strong><\/p>\n<\/p>\n<p><p>\u9664\u4e86\u4f7f\u7528\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u4f60\u8fd8\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u6765\u7f16\u5199\u548c\u8fd0\u884cPython\u4ee3\u7801\u3002\u5e38\u89c1\u7684Python IDE\u6709PyCharm\u3001Visual Studio Code\u3001Jupyter Notebook\u7b49\u3002\u9009\u62e9\u5408\u9002\u7684IDE\u53ef\u4ee5\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\uff0c\u63d0\u4f9b\u4ee3\u7801\u8865\u5168\u3001\u8c03\u8bd5\u7b49\u529f\u80fd\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5\u548c\u914d\u7f6eIDE<\/strong><\/p>\n<\/p>\n<p><p>\u4ee5PyCharm\u4e3a\u4f8b\uff0c\u4f60\u53ef\u4ee5\u4ece\u5176\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u793e\u533a\u7248\u6216\u4e13\u4e1a\u7248\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u901a\u8fc7\u521b\u5efa\u65b0\u9879\u76ee\u6765\u5f00\u59cb\u4f60\u7684Python\u7f16\u7a0b\u4e4b\u65c5\u3002\u5728\u9879\u76ee\u8bbe\u7f6e\u4e2d\uff0c\u4f60\u53ef\u4ee5\u6307\u5b9aPython\u89e3\u91ca\u5668\u7684\u8def\u5f84\uff0c\u786e\u4fdd\u4f60\u7684\u9879\u76ee\u80fd\u591f\u6b63\u786e\u8bc6\u522b\u548c\u4f7f\u7528Python\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e0b\u8fd0\u884cPython\u811a\u672c<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u7f16\u5199Python\u811a\u672c<\/strong><\/p>\n<\/p>\n<p><p>\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\uff08\u5982Notepad++\u3001Sublime Text\uff09\u7f16\u5199\u4f60\u7684Python\u4ee3\u7801\uff0c\u5e76\u5c06\u5176\u4fdd\u5b58\u4e3a<code>.py<\/code>\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\u5c06\u4ee5\u4e0b\u4ee3\u7801\u4fdd\u5b58\u4e3a<code>hello.py<\/code>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">print(&quot;Hello, World!&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884cPython\u811a\u672c<\/strong><\/p>\n<\/p>\n<p><p>\u5728Windows\u64cd\u4f5c\u7cfb\u7edf\u4e0b\uff0c\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u5bfc\u822a\u5230\u4f60\u7684Python\u811a\u672c\u6240\u5728\u7684\u76ee\u5f55\u3002\u7136\u540e\u8f93\u5165<code>python hello.py<\/code>\u6216<code>python3 hello.py<\/code>\u6765\u8fd0\u884c\u811a\u672c\u3002\u4f60\u5e94\u8be5\u80fd\u770b\u5230\u8f93\u51fa\u7ed3\u679c\u201cHello, World!\u201d\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf<\/p>\n<\/p>\n<p><p><strong>\u786e\u4fddPython\u73af\u5883\u53d8\u91cf\u8bbe\u7f6e\u6b63\u786e<\/strong>\u3002\u5982\u679c\u5b89\u88c5Python\u65f6\u6ca1\u6709\u9009\u62e9\u81ea\u52a8\u6dfb\u52a0\u5230\u73af\u5883\u53d8\u91cf\uff0c\u4f60\u9700\u8981\u624b\u52a8\u5c06Python\u5b89\u88c5\u76ee\u5f55\u6dfb\u52a0\u5230\u7cfb\u7edf\u7684PATH\u53d8\u91cf\u4e2d\u3002\u8fd9\u6837\u53ef\u4ee5\u786e\u4fdd\u4f60\u5728\u4efb\u4f55\u76ee\u5f55\u4e0b\u90fd\u80fd\u901a\u8fc7\u547d\u4ee4\u63d0\u793a\u7b26\u8fd0\u884cPython\u3002<\/p>\n<\/p>\n<p><p>\u4e94\u3001\u4f7f\u7528\u5305\u7ba1\u7406\u5668pip<\/p>\n<\/p>\n<p><p><strong>\u4e86\u89e3\u5982\u4f55\u4f7f\u7528pip\u5b89\u88c5Python\u5305<\/strong>\u3002pip\u662fPython\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u7528\u4e8e\u5b89\u88c5\u548c\u7ba1\u7406Python\u5e93\u548c\u4f9d\u8d56\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4<code>pip install package_name<\/code>\u6765\u5b89\u88c5\u6240\u9700\u7684Python\u5305\uff0c\u4ece\u800c\u6269\u5c55Python\u7684\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><p>\u516d\u3001\u4e86\u89e3Python\u7248\u672c\u7ba1\u7406<\/p>\n<\/p>\n<p><p><strong>\u638c\u63e1Python\u7248\u672c\u7ba1\u7406\u5de5\u5177<\/strong>\u3002\u5982\u679c\u4f60\u7684\u9879\u76ee\u9700\u8981\u4e0d\u540c\u7248\u672c\u7684Python\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u5de5\u5177\u5982<code>pyenv<\/code>\u6765\u7ba1\u7406\u591a\u4e2aPython\u7248\u672c\u3002\u8fd9\u5bf9\u4e8e\u5f00\u53d1\u4e0d\u540cPython\u7248\u672c\u7684\u9879\u76ee\u975e\u5e38\u6709\u7528\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u8fd9\u4e9b\u6b65\u9aa4\uff0c\u4f60\u5c31\u53ef\u4ee5\u5728PC\u4e0a\u987a\u5229\u6253\u5f00\u548c\u8fd0\u884cPython\u4e86\u3002Python\u7684\u5f3a\u5927\u4e4b\u5904\u5728\u4e8e\u5176\u7b80\u5355\u6613\u7528\u7684\u8bed\u6cd5\u548c\u4e30\u5bcc\u7684\u5e93\u652f\u6301\uff0c\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u548c\u65b9\u6cd5\u53ef\u4ee5\u8ba9\u4f60\u7684Python\u5f00\u53d1\u4f53\u9a8c\u66f4\u52a0\u9ad8\u6548\u548c\u6109\u60a6\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Windows PC\u4e0a\u5b89\u88c5Python\uff1f<\/strong><br \/>\u8981\u5728Windows PC\u4e0a\u5b89\u88c5Python\uff0c\u9996\u5148\u8bbf\u95eePython\u5b98\u65b9\u7f51\u7ad9\uff0c\u4e0b\u8f7d\u9002\u5408\u60a8\u7cfb\u7edf\u7684\u6700\u65b0\u7248\u672c\u7684\u5b89\u88c5\u7a0b\u5e8f\u3002\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u53cc\u51fb\u5b89\u88c5\u7a0b\u5e8f\uff0c\u786e\u4fdd\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u52fe\u9009\u201cAdd Python to PATH\u201d\u9009\u9879\u3002\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165<code>python<\/code>\u6765\u9a8c\u8bc1\u662f\u5426\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Python\u4e2d\u8fd0\u884c\u811a\u672c\uff1f<\/strong><br \/>\u5728Windows PC\u4e0a\u8fd0\u884cPython\u811a\u672c\u975e\u5e38\u7b80\u5355\u3002\u60a8\u53ea\u9700\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff0c\u5bfc\u822a\u5230\u811a\u672c\u6240\u5728\u7684\u76ee\u5f55\uff0c\u5e76\u8f93\u5165<code>python script_name.py<\/code>\u3002\u786e\u4fdd\u5c06\u201cscript_name.py\u201d\u66ff\u6362\u4e3a\u60a8\u7684\u5b9e\u9645\u6587\u4ef6\u540d\u3002\u5982\u679c\u4e00\u5207\u6b63\u5e38\uff0c\u60a8\u7684\u811a\u672c\u5c06\u5f00\u59cb\u6267\u884c\u3002<\/p>\n<p><strong>\u5982\u4f55\u89e3\u51b3Python\u5728PC\u4e0a\u65e0\u6cd5\u6253\u5f00\u7684\u95ee\u9898\uff1f<\/strong><br \/>\u5982\u679c\u60a8\u5728\u5c1d\u8bd5\u6253\u5f00Python\u65f6\u9047\u5230\u95ee\u9898\uff0c\u9996\u5148\u68c0\u67e5\u662f\u5426\u6b63\u786e\u5b89\u88c5\u4e86Python\uff0c\u5e76\u786e\u8ba4\u73af\u5883\u53d8\u91cf\u8bbe\u7f6e\u65e0\u8bef\u3002\u60a8\u53ef\u4ee5\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165<code>python --version<\/code>\u6765\u68c0\u67e5Python\u7248\u672c\u3002\u5982\u679c\u663e\u793a\u9519\u8bef\u6d88\u606f\uff0c\u8bf7\u91cd\u65b0\u5b89\u88c5\u6216\u68c0\u67e5\u60a8\u7684\u7cfb\u7edf\u8def\u5f84\u8bbe\u7f6e\u3002\u5982\u679c\u95ee\u9898\u4f9d\u7136\u5b58\u5728\uff0c\u8003\u8651\u67e5\u9605Python\u793e\u533a\u8bba\u575b\u6216\u5b98\u65b9\u6587\u6863\u83b7\u53d6\u66f4\u591a\u5e2e\u52a9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u5728PC\u4e0a\u6253\u5f00Python\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u5b89\u88c5Python\u89e3\u91ca\u5668\u3001\u4f7f\u7528Python IDE\u3001\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e0b\u8fd0\u884cPy [&hellip;]","protected":false},"author":3,"featured_media":931346,"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\/931345"}],"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=931345"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/931345\/revisions"}],"predecessor-version":[{"id":931347,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/931345\/revisions\/931347"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/931346"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=931345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=931345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=931345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}