{"id":977356,"date":"2024-12-27T06:28:54","date_gmt":"2024-12-26T22:28:54","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/977356.html"},"modified":"2024-12-27T06:28:56","modified_gmt":"2024-12-26T22:28:56","slug":"%e5%a6%82%e4%bd%95%e5%ae%89%e8%a3%85python%e8%bf%90%e8%a1%8c%e5%8a%a9%e6%89%8b","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/977356.html","title":{"rendered":"\u5982\u4f55\u5b89\u88c5python\u8fd0\u884c\u52a9\u624b"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24202638\/5b2126ac-4928-41be-a215-66de64ea62d6.webp\" alt=\"\u5982\u4f55\u5b89\u88c5python\u8fd0\u884c\u52a9\u624b\" \/><\/p>\n<p><p> <strong>\u5b89\u88c5Python\u8fd0\u884c\u52a9\u624b\u6709\u4ee5\u4e0b\u51e0\u4e2a\u5173\u952e\u6b65\u9aa4\uff1a\u4e0b\u8f7dPython\u5b89\u88c5\u5305\u3001\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3002\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u786e\u4fdd\u9009\u62e9\u4e86\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u8fd9\u5c06\u81ea\u52a8\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u4f7f\u5f97Python\u547d\u4ee4\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u76f4\u63a5\u4f7f\u7528\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u6bcf\u4e2a\u6b65\u9aa4\uff0c\u4ee5\u786e\u4fdd\u60a8\u80fd\u591f\u987a\u5229\u5b89\u88c5\u5e76\u8fd0\u884cPython\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4e0b\u8f7dPython\u5b89\u88c5\u5305<\/p>\n<\/p>\n<p><p>\u5728\u5b89\u88c5Python\u8fd0\u884c\u52a9\u624b\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u4e0b\u8f7dPython\u7684\u5b89\u88c5\u5305\u3002Python\u7684\u5b98\u65b9\u7f51\u7ad9\u63d0\u4f9b\u4e86\u4e0d\u540c\u7248\u672c\u7684Python\u5b89\u88c5\u5305\uff0c\u60a8\u53ef\u4ee5\u6839\u636e\u9700\u8981\u9009\u62e9\u5408\u9002\u7684\u7248\u672c\u3002\u901a\u5e38\uff0c\u5bf9\u4e8e\u5927\u591a\u6570\u7528\u6237\u6765\u8bf4\uff0c\u4e0b\u8f7d\u6700\u65b0\u7684\u7a33\u5b9a\u7248\u672c\u662f\u6700\u4f73\u9009\u62e9\u3002<\/p>\n<\/p>\n<ul>\n<li><strong>\u9009\u62e9\u5408\u9002\u7684\u7248\u672c<\/strong>\uff1aPython\u4e3b\u8981\u6709Python 2\u548cPython 3\u4e24\u4e2a\u7248\u672c\u7cfb\u5217\u3002\u7531\u4e8ePython 2\u5df2\u505c\u6b62\u5b98\u65b9\u652f\u6301\uff0c\u5efa\u8bae\u9009\u62e9Python 3\u7248\u672c\u3002<\/li>\n<li><strong>\u4e0b\u8f7d\u5b89\u88c5\u5305<\/strong>\uff1a\u8bbf\u95eePython\u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/www.python.org\/%EF%BC%89%EF%BC%8C%E5%9C%A8%E2%80%9CDownloads%E2%80%9D%E9%A1%B5%E9%9D%A2%E9%80%89%E6%8B%A9%E9%80%82%E5%90%88%E6%82%A8%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E7%9A%84Python%E7%89%88%E6%9C%AC%EF%BC%8C%E7%82%B9%E5%87%BB%E4%B8%8B%E8%BD%BD%E3%80%82\">https:\/\/www.python.org\/\uff09\uff0c\u5728\u201cDownloads\u201d\u9875\u9762\u9009\u62e9\u9002\u5408\u60a8\u64cd\u4f5c\u7cfb\u7edf\u7684Python\u7248\u672c\uff0c\u70b9\u51fb\u4e0b\u8f7d\u3002<\/a><\/li>\n<\/ul>\n<p><p>\u4e8c\u3001\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f<\/p>\n<\/p>\n<p><p>\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u60a8\u9700\u8981\u8fd0\u884c\u4e0b\u8f7d\u7684\u5b89\u88c5\u7a0b\u5e8f\u6765\u5f00\u59cb\u5b89\u88c5Python\u3002<\/p>\n<\/p>\n<ul>\n<li><strong>\u5f00\u59cb\u5b89\u88c5<\/strong>\uff1a\u53cc\u51fb\u4e0b\u8f7d\u7684\u5b89\u88c5\u5305\u6587\u4ef6\uff0c\u5b89\u88c5\u7a0b\u5e8f\u4f1a\u542f\u52a8\u3002\u60a8\u5c06\u770b\u5230\u4e00\u4e2a\u5b89\u88c5\u9009\u9879\u754c\u9762\u3002<\/li>\n<li><strong>\u9009\u62e9\u5b89\u88c5\u9009\u9879<\/strong>\uff1a\u5728\u7b2c\u4e00\u4e2a\u5b89\u88c5\u754c\u9762\uff0c\u786e\u4fdd\u9009\u4e2d\u4e86\u201cAdd Python to PATH\u201d\u9009\u9879\u3002\u8fd9\u4e00\u6b65\u975e\u5e38\u91cd\u8981\uff0c\u53ef\u4ee5\u5e2e\u52a9\u60a8\u5728\u547d\u4ee4\u884c\u4e2d\u76f4\u63a5\u4f7f\u7528Python\u547d\u4ee4\u3002<\/li>\n<li><strong>\u81ea\u5b9a\u4e49\u5b89\u88c5<\/strong>\uff1a\u5982\u679c\u60a8\u9700\u8981\u81ea\u5b9a\u4e49\u5b89\u88c5\u8def\u5f84\u6216\u7ec4\u4ef6\uff0c\u53ef\u4ee5\u9009\u62e9\u201cCustomize installation\u201d\u9009\u9879\u3002\u5426\u5219\uff0c\u76f4\u63a5\u9009\u62e9\u201cInstall Now\u201d\u5373\u53ef\u8fdb\u884c\u9ed8\u8ba4\u5b89\u88c5\u3002<\/li>\n<\/ul>\n<p><p>\u4e09\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf<\/p>\n<\/p>\n<p><p>\u867d\u7136\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u5df2\u7ecf\u9009\u62e9\u4e86\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u4f46\u5982\u679c\u60a8\u9047\u5230Python\u547d\u4ee4\u65e0\u6cd5\u8bc6\u522b\u7684\u95ee\u9898\uff0c\u53ef\u80fd\u9700\u8981\u624b\u52a8\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3002<\/p>\n<\/p>\n<ul>\n<li><strong>\u68c0\u67e5\u73af\u5883\u53d8\u91cf<\/strong>\uff1a\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u53f3\u952e\u5355\u51fb\u201c\u6b64\u7535\u8111\u201d\uff0c\u9009\u62e9\u201c\u5c5e\u6027\u201d\uff0c\u7136\u540e\u9009\u62e9\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d\uff0c\u70b9\u51fb\u201c\u73af\u5883\u53d8\u91cf\u201d\u3002<\/li>\n<li><strong>\u7f16\u8f91PATH\u53d8\u91cf<\/strong>\uff1a\u5728\u201c\u7cfb\u7edf\u53d8\u91cf\u201d\u90e8\u5206\uff0c\u627e\u5230\u5e76\u7f16\u8f91\u201cPath\u201d\u53d8\u91cf\uff0c\u786e\u4fddPython\u7684\u5b89\u88c5\u8def\u5f84\u548cScripts\u8def\u5f84\u5728\u5176\u4e2d\uff08\u4f8b\u5982\uff1aC:\\Python39\u548cC:\\Python39\\Scripts\uff09\u3002<\/li>\n<li><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong>\uff1a\u6253\u5f00\u547d\u4ee4\u63d0\u793a\u7b26\uff08CMD\uff09\uff0c\u8f93\u5165<code>python --version<\/code>\u548c<code>pip --version<\/code>\uff0c\u5982\u679c\u8fd4\u56dePython\u548cpip\u7684\u7248\u672c\u53f7\uff0c\u8bf4\u660ePython\u5b89\u88c5\u6210\u529f\u3002<\/li>\n<\/ul>\n<p><p>\u56db\u3001\u5b89\u88c5Python\u8fd0\u884c\u52a9\u624b<\/p>\n<\/p>\n<p><p>\u6709\u65f6\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u5b89\u88c5\u4e00\u4e9bPython\u8fd0\u884c\u52a9\u624b\u6765\u5e2e\u52a9\u5f00\u53d1\uff0c\u4f8b\u5982IDE\u6216\u5305\u7ba1\u7406\u5de5\u5177\u3002<\/p>\n<\/p>\n<ul>\n<li><strong>\u9009\u62e9IDE<\/strong>\uff1a\u5e38\u7528\u7684Python IDE\u5305\u62ecPyCharm\u3001Visual Studio Code\u548cJupyter Notebook\u3002\u6839\u636e\u4e2a\u4eba\u559c\u597d\u9009\u62e9\u5408\u9002\u7684IDE\u3002<\/li>\n<li><strong>\u5b89\u88c5pip\u5305\u7ba1\u7406\u5de5\u5177<\/strong>\uff1apip\u662fPython\u7684\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u901a\u5e38\u5728Python\u5b89\u88c5\u65f6\u4f1a\u81ea\u52a8\u5b89\u88c5\u3002\u5982\u679c\u672a\u5b89\u88c5\uff0c\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4<code>python -m ensurepip --default-pip<\/code>\u8fdb\u884c\u5b89\u88c5\u3002<\/li>\n<li><strong>\u4f7f\u7528pip\u5b89\u88c5\u5305<\/strong>\uff1a\u901a\u8fc7\u547d\u4ee4\u884c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528pip\u5b89\u88c5\u5404\u79cdPython\u5305\uff0c\u4f8b\u5982<code>pip install numpy<\/code>\u3002<\/li>\n<\/ul>\n<p><p>\u4e94\u3001\u89e3\u51b3\u5b89\u88c5\u4e2d\u7684\u5e38\u89c1\u95ee\u9898<\/p>\n<\/p>\n<p><p>\u5728\u5b89\u88c5Python\u53ca\u5176\u76f8\u5173\u5de5\u5177\u65f6\uff0c\u60a8\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u5e38\u89c1\u95ee\u9898\u3002\u4e86\u89e3\u5e76\u89e3\u51b3\u8fd9\u4e9b\u95ee\u9898\u53ef\u4ee5\u5e2e\u52a9\u60a8\u66f4\u987a\u5229\u5730\u5b89\u88c5Python\u3002<\/p>\n<\/p>\n<ul>\n<li><strong>\u5b89\u88c5\u5931\u8d25\u6216\u5361\u4f4f<\/strong>\uff1a\u786e\u4fdd\u4e0b\u8f7d\u7684\u5b89\u88c5\u5305\u5b8c\u6574\u65e0\u8bef\uff0c\u6216\u8005\u5c1d\u8bd5\u91cd\u65b0\u4e0b\u8f7d\u3002<\/li>\n<li><strong>\u65e0\u6cd5\u8bc6\u522bPython\u547d\u4ee4<\/strong>\uff1a\u68c0\u67e5\u73af\u5883\u53d8\u91cf\u914d\u7f6e\u662f\u5426\u6b63\u786e\u3002<\/li>\n<li><strong>\u7f3a\u5c11\u6743\u9650<\/strong>\uff1a\u5982\u679c\u5b89\u88c5\u65f6\u63d0\u793a\u6743\u9650\u4e0d\u8db3\uff0c\u8bf7\u5c1d\u8bd5\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f\u3002<\/li>\n<\/ul>\n<p><p>\u516d\u3001\u521d\u6b21\u4f7f\u7528Python<\/p>\n<\/p>\n<p><p>\u5b8c\u6210\u4ee5\u4e0a\u6b65\u9aa4\u540e\uff0c\u60a8\u53ef\u4ee5\u5f00\u59cb\u4f7f\u7528Python\u8fdb\u884c\u5f00\u53d1\u3002<\/p>\n<\/p>\n<ul>\n<li><strong>\u8fd0\u884cPython\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668<\/strong>\uff1a\u5728\u547d\u4ee4\u63d0\u793a\u7b26\u4e2d\u8f93\u5165<code>python<\/code>\uff0c\u53ef\u4ee5\u8fdb\u5165Python\u4ea4\u4e92\u5f0f\u89e3\u91ca\u5668\uff0c\u5c1d\u8bd5\u8f93\u5165<code>print(&quot;Hello, World!&quot;)<\/code>\u6765\u6d4b\u8bd5\u3002<\/li>\n<li><strong>\u7f16\u5199Python\u811a\u672c<\/strong>\uff1a\u4f7f\u7528IDE\u521b\u5efa\u4e00\u4e2aPython\u6587\u4ef6\uff08\u4f8b\u5982\uff1atest.py\uff09\uff0c\u7f16\u5199\u7b80\u5355\u7684Python\u4ee3\u7801\u5e76\u8fd0\u884c\u3002<\/li>\n<li><strong>\u5b89\u88c5\u548c\u4f7f\u7528\u7b2c\u4e09\u65b9\u5e93<\/strong>\uff1a\u901a\u8fc7pip\u5b89\u88c5\u9700\u8981\u7684\u7b2c\u4e09\u65b9\u5e93\uff0c\u5982<code>pip install requests<\/code>\uff0c\u5e76\u5728\u4ee3\u7801\u4e2d\u4f7f\u7528<code>import requests<\/code>\u8fdb\u884c\u8c03\u7528\u3002<\/li>\n<\/ul>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u60a8\u5e94\u8be5\u80fd\u591f\u6210\u529f\u5b89\u88c5\u5e76\u5f00\u59cb\u4f7f\u7528Python\u8fdb\u884c\u5f00\u53d1\u3002Python\u7684\u7075\u6d3b\u6027\u548c\u5e7f\u6cdb\u7684\u793e\u533a\u652f\u6301\u4f7f\u5176\u6210\u4e3a\u4e00\u95e8\u975e\u5e38\u53d7\u6b22\u8fce\u7684\u7f16\u7a0b\u8bed\u8a00\uff0c\u65e0\u8bba\u662f\u521d\u5b66\u8005\u8fd8\u662f\u4e13\u4e1a\u5f00\u53d1\u8005\u90fd\u80fd\u4ece\u4e2d\u53d7\u76ca\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u9009\u62e9\u9002\u5408\u6211\u64cd\u4f5c\u7cfb\u7edf\u7684Python\u8fd0\u884c\u52a9\u624b\u7248\u672c\uff1f<\/strong><br \/>\u5728\u5b89\u88c5Python\u8fd0\u884c\u52a9\u624b\u4e4b\u524d\uff0c\u4e86\u89e3\u60a8\u7684\u64cd\u4f5c\u7cfb\u7edf\u662f\u81f3\u5173\u91cd\u8981\u7684\u3002\u4e0d\u540c\u7684\u64cd\u4f5c\u7cfb\u7edf\uff08\u5982Windows\u3001macOS\u548cLinux\uff09\u53ef\u80fd\u9700\u8981\u4e0d\u540c\u7684\u5b89\u88c5\u5305\u3002\u60a8\u53ef\u4ee5\u8bbf\u95eePython\u5b98\u65b9\u7f51\u7ad9\uff0c\u67e5\u770b\u9488\u5bf9\u7279\u5b9a\u64cd\u4f5c\u7cfb\u7edf\u7684\u4e0b\u8f7d\u9009\u9879\u3002\u786e\u4fdd\u4e0b\u8f7d\u4e0e\u60a8\u7684\u64cd\u4f5c\u7cfb\u7edf\u7248\u672c\u517c\u5bb9\u7684\u8fd0\u884c\u52a9\u624b\uff0c\u4ee5\u907f\u514d\u6f5c\u5728\u7684\u5b89\u88c5\u95ee\u9898\u3002<\/p>\n<p><strong>\u5b89\u88c5Python\u8fd0\u884c\u52a9\u624b\u540e\uff0c\u6211\u5e94\u8be5\u5982\u4f55\u914d\u7f6e\u73af\u5883\u53d8\u91cf\uff1f<\/strong><br \/>\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u662f\u786e\u4fddPython\u8fd0\u884c\u52a9\u624b\u80fd\u591f\u6b63\u5e38\u5de5\u4f5c\u7684\u5173\u952e\u6b65\u9aa4\u3002\u5bf9\u4e8eWindows\u7528\u6237\uff0c\u53ef\u4ee5\u901a\u8fc7\u7cfb\u7edf\u5c5e\u6027\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u6dfb\u52a0Python\u7684\u5b89\u88c5\u8def\u5f84\u5230\u201cPath\u201d\u53d8\u91cf\u4e2d\u3002\u5bf9\u4e8emacOS\u548cLinux\u7528\u6237\uff0c\u901a\u5e38\u9700\u8981\u5728\u7ec8\u7aef\u4e2d\u4fee\u6539.bash_profile\u6216.zshrc\u6587\u4ef6\uff0c\u5c06Python\u5b89\u88c5\u8def\u5f84\u6dfb\u52a0\u5230PATH\u53d8\u91cf\u4e2d\u3002\u5b8c\u6210\u540e\uff0c\u8bb0\u5f97\u91cd\u542f\u7ec8\u7aef\uff0c\u4ee5\u4f7f\u66f4\u6539\u751f\u6548\u3002<\/p>\n<p><strong>\u4f7f\u7528Python\u8fd0\u884c\u52a9\u624b\u65f6\u9047\u5230\u9519\u8bef\uff0c\u5982\u4f55\u8fdb\u884c\u6545\u969c\u6392\u9664\uff1f<\/strong><br \/>\u5728\u4f7f\u7528Python\u8fd0\u884c\u52a9\u624b\u7684\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u5404\u79cd\u9519\u8bef\u3002\u9996\u5148\uff0c\u53ef\u4ee5\u67e5\u770b\u9519\u8bef\u4fe1\u606f\uff0c\u4e86\u89e3\u95ee\u9898\u7684\u6765\u6e90\u3002\u5e38\u89c1\u7684\u95ee\u9898\u5305\u62ec\u4f9d\u8d56\u5e93\u672a\u5b89\u88c5\u3001\u7248\u672c\u4e0d\u517c\u5bb9\u7b49\u3002\u67e5\u9605\u8fd0\u884c\u52a9\u624b\u7684\u6587\u6863\u6216\u793e\u533a\u8bba\u575b\uff0c\u901a\u5e38\u53ef\u4ee5\u627e\u5230\u89e3\u51b3\u65b9\u6848\u3002\u5982\u679c\u95ee\u9898\u4f9d\u65e7\uff0c\u8003\u8651\u91cd\u88c5Python\u8fd0\u884c\u52a9\u624b\uff0c\u786e\u4fdd\u60a8\u4e0b\u8f7d\u7684\u662f\u6700\u65b0\u7248\u672c\uff0c\u5e76\u4e14\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u6ca1\u6709\u9057\u6f0f\u4efb\u4f55\u6b65\u9aa4\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5b89\u88c5Python\u8fd0\u884c\u52a9\u624b\u6709\u4ee5\u4e0b\u51e0\u4e2a\u5173\u952e\u6b65\u9aa4\uff1a\u4e0b\u8f7dPython\u5b89\u88c5\u5305\u3001\u8fd0\u884c\u5b89\u88c5\u7a0b\u5e8f\u3001\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3002\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c [&hellip;]","protected":false},"author":3,"featured_media":977366,"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\/977356"}],"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=977356"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/977356\/revisions"}],"predecessor-version":[{"id":977368,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/977356\/revisions\/977368"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/977366"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=977356"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=977356"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=977356"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}