{"id":1083629,"date":"2025-01-08T12:59:46","date_gmt":"2025-01-08T04:59:46","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1083629.html"},"modified":"2025-01-08T12:59:48","modified_gmt":"2025-01-08T04:59:48","slug":"%e7%94%a8%e7%bc%96%e8%be%91%e5%99%a8%e5%86%99%e4%ba%86python%e5%a6%82%e4%bd%95%e8%bf%90%e8%a1%8c-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1083629.html","title":{"rendered":"\u7528\u7f16\u8f91\u5668\u5199\u4e86python\u5982\u4f55\u8fd0\u884c"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24194112\/59983630-5870-41e2-80dc-141436715e2f.webp\" alt=\"\u7528\u7f16\u8f91\u5668\u5199\u4e86python\u5982\u4f55\u8fd0\u884c\" \/><\/p>\n<p><p> \u4e00\u3001\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\u7f16\u5199Python\u4ee3\u7801\u5e76\u8fd0\u884c\u7684\u65b9\u6cd5\u6709\u5f88\u591a\u79cd\uff0c\u5305\u62ec\uff1a\u9009\u62e9\u5408\u9002\u7684\u6587\u672c\u7f16\u8f91\u5668\u3001\u5b89\u88c5Python\u89e3\u91ca\u5668\u3001\u7f16\u5199\u5e76\u4fdd\u5b58Python\u811a\u672c\u3001\u4f7f\u7528\u547d\u4ee4\u884c\u8fd0\u884c\u811a\u672c\u3002<strong>\u9009\u62e9\u5408\u9002\u7684\u6587\u672c\u7f16\u8f91\u5668\u3001\u5b89\u88c5Python\u89e3\u91ca\u5668\u3001\u7f16\u5199\u5e76\u4fdd\u5b58Python\u811a\u672c\u3001\u4f7f\u7528\u547d\u4ee4\u884c\u8fd0\u884c\u811a\u672c<\/strong>\u3002\u4e0b\u9762\u6211\u4eec\u5c06\u8be6\u7ec6\u8ba8\u8bba\u8fd9\u4e9b\u6b65\u9aa4\uff0c\u5176\u4e2d\u9009\u62e9\u5408\u9002\u7684\u6587\u672c\u7f16\u8f91\u5668\u662f\u975e\u5e38\u91cd\u8981\u7684\u4e00\u6b65\uff0c\u56e0\u4e3a\u4e00\u4e2a\u597d\u7684\u7f16\u8f91\u5668\u53ef\u4ee5\u5927\u5927\u63d0\u9ad8\u7f16\u7a0b\u6548\u7387\u548c\u7f16\u5199\u4ee3\u7801\u7684\u8d28\u91cf\u3002<\/p>\n<\/p>\n<p><p>\u9009\u62e9\u5408\u9002\u7684\u6587\u672c\u7f16\u8f91\u5668\u662f\u7f16\u5199Python\u4ee3\u7801\u7684\u7b2c\u4e00\u6b65\u3002\u5e38\u89c1\u7684\u6587\u672c\u7f16\u8f91\u5668\u5305\u62ecSublime Text\u3001Visual Studio Code\u3001PyCharm\u7b49\u3002\u8fd9\u4e9b\u7f16\u8f91\u5668\u63d0\u4f9b\u4e86\u8bed\u6cd5\u9ad8\u4eae\u3001\u4ee3\u7801\u81ea\u52a8\u8865\u5168\u3001\u8c03\u8bd5\u5de5\u5177\u7b49\u529f\u80fd\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u66f4\u9ad8\u6548\u5730\u7f16\u5199\u548c\u8c03\u8bd5\u4ee3\u7801\u3002\u4f8b\u5982\uff0cVisual Studio Code\u4e0d\u4ec5\u652f\u6301\u591a\u79cd\u7f16\u7a0b\u8bed\u8a00\uff0c\u8fd8\u62e5\u6709\u5f3a\u5927\u7684\u6269\u5c55\u529f\u80fd\uff0c\u53ef\u4ee5\u901a\u8fc7\u5b89\u88c5\u4e0d\u540c\u7684\u63d2\u4ef6\u6765\u589e\u5f3a\u7f16\u8f91\u5668\u7684\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u9009\u62e9\u5408\u9002\u7684\u6587\u672c\u7f16\u8f91\u5668<\/p>\n<\/p>\n<p><p>\u9009\u62e9\u4e00\u4e2a\u9002\u5408\u81ea\u5df1\u7684\u6587\u672c\u7f16\u8f91\u5668\u662f\u7f16\u5199Python\u4ee3\u7801\u7684\u7b2c\u4e00\u6b65\u3002\u4ee5\u4e0b\u662f\u51e0\u79cd\u5e38\u7528\u7684\u6587\u672c\u7f16\u8f91\u5668\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p>Sublime Text<\/p>\n<p>Sublime Text\u662f\u4e00\u6b3e\u8f7b\u91cf\u7ea7\u7684\u6587\u672c\u7f16\u8f91\u5668\uff0c\u652f\u6301\u591a\u79cd\u7f16\u7a0b\u8bed\u8a00\uff0c\u5305\u62ecPython\u3002\u5b83\u5177\u6709\u5feb\u901f\u542f\u52a8\u3001\u5f3a\u5927\u7684\u63d2\u4ef6\u7cfb\u7edf\u548c\u6613\u4e8e\u4f7f\u7528\u7684\u754c\u9762\u3002Sublime Text\u7684\u4f18\u70b9\u662f\u542f\u52a8\u901f\u5ea6\u5feb\uff0c\u5360\u7528\u8d44\u6e90\u5c11\uff0c\u9002\u5408\u9700\u8981\u5feb\u901f\u7f16\u5199\u548c\u6d4b\u8bd5\u4ee3\u7801\u7684\u5f00\u53d1\u8005\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>Visual Studio Code<\/p>\n<p>Visual Studio Code\uff08VS Code\uff09\u662f\u7531\u5fae\u8f6f\u5f00\u53d1\u7684\u4e00\u6b3e\u5f00\u6e90\u7f16\u8f91\u5668\uff0c\u652f\u6301\u591a\u79cd\u7f16\u7a0b\u8bed\u8a00\uff0c\u5e76\u4e14\u5177\u6709\u5f3a\u5927\u7684\u6269\u5c55\u529f\u80fd\u3002VS Code\u5185\u7f6e\u4e86\u8bb8\u591a\u6709\u7528\u7684\u529f\u80fd\uff0c\u5982\u8bed\u6cd5\u9ad8\u4eae\u3001\u4ee3\u7801\u8865\u5168\u3001\u8c03\u8bd5\u5de5\u5177\u7b49\u3002\u901a\u8fc7\u5b89\u88c5Python\u6269\u5c55\uff0c\u53ef\u4ee5\u83b7\u5f97\u66f4\u52a0\u5168\u9762\u7684Python\u5f00\u53d1\u652f\u6301\uff0c\u5305\u62ec\u8c03\u8bd5\u3001Linting\u3001\u4ee3\u7801\u683c\u5f0f\u5316\u7b49\u529f\u80fd\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>PyCharm<\/p>\n<p>PyCharm\u662f\u7531JetBr<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>ns\u5f00\u53d1\u7684\u4e00\u6b3e\u4e13\u4e1aPython\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\uff0c\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u529f\u80fd\uff0c\u5982\u667a\u80fd\u4ee3\u7801\u8865\u5168\u3001\u4ee3\u7801\u91cd\u6784\u3001\u8c03\u8bd5\u5de5\u5177\u3001\u7248\u672c\u63a7\u5236\u652f\u6301\u7b49\u3002PyCharm\u5206\u4e3a\u793e\u533a\u7248\uff08\u514d\u8d39\uff09\u548c\u4e13\u4e1a\u7248\uff08\u6536\u8d39\uff09\uff0c\u9002\u5408\u9700\u8981\u5168\u9762\u5f00\u53d1\u5de5\u5177\u652f\u6301\u7684Python\u5f00\u53d1\u8005\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u5b89\u88c5Python\u89e3\u91ca\u5668<\/p>\n<\/p>\n<p><p>\u5728\u7f16\u5199Python\u4ee3\u7801\u4e4b\u524d\uff0c\u9700\u8981\u5728\u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5Python\u89e3\u91ca\u5668\u3002Python\u89e3\u91ca\u5668\u662f\u8fd0\u884cPython\u4ee3\u7801\u7684\u6838\u5fc3\u5de5\u5177\u3002\u4ee5\u4e0b\u662f\u5b89\u88c5Python\u89e3\u91ca\u5668\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p>\u4e0b\u8f7dPython\u5b89\u88c5\u5305<\/p>\n<p>\u8bbf\u95eePython\u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/www.python.org\/%EF%BC%89%EF%BC%8C%E5%9C%A8%E4%B8%8B%E8%BD%BD%E9%A1%B5%E9%9D%A2%E9%80%89%E6%8B%A9%E9%80%82%E5%90%88%E8%87%AA%E5%B7%B1%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E7%9A%84%E5%AE%89%E8%A3%85%E5%8C%85%E3%80%82%E4%B8%80%E8%88%AC%E6%9D%A5%E8%AF%B4%EF%BC%8C%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\u5728\u4e0b\u8f7d\u9875\u9762\u9009\u62e9\u9002\u5408\u81ea\u5df1\u64cd\u4f5c\u7cfb\u7edf\u7684\u5b89\u88c5\u5305\u3002\u4e00\u822c\u6765\u8bf4\uff0c\u5efa\u8bae\u9009\u62e9\u6700\u65b0\u7684\u7a33\u5b9a\u7248\u672c\u3002<\/a><\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u5b89\u88c5Python<\/p>\n<p>\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u8fd0\u884c\u5b89\u88c5\u5305\u5e76\u6309\u7167\u63d0\u793a\u8fdb\u884c\u5b89\u88c5\u3002\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u786e\u4fdd\u52fe\u9009\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u8fd9\u5c06\u65b9\u4fbf\u540e\u7eed\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884cPython\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u9a8c\u8bc1\u5b89\u88c5<\/p>\n<p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6253\u5f00\u547d\u4ee4\u884c\uff08Windows\u7528\u6237\u53ef\u4ee5\u4f7f\u7528cmd\u6216PowerShell\uff0cmacOS\u548cLinux\u7528\u6237\u53ef\u4ee5\u4f7f\u7528\u7ec8\u7aef\uff09\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u9a8c\u8bc1Python\u662f\u5426\u5b89\u88c5\u6210\u529f\uff1a<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><pre><code class=\"language-sh\">python --version<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u663e\u793aPython\u7248\u672c\u53f7\uff0c\u8bf4\u660e\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u7f16\u5199\u5e76\u4fdd\u5b58Python\u811a\u672c<\/p>\n<\/p>\n<p><p>\u5728\u9009\u62e9\u4e86\u6587\u672c\u7f16\u8f91\u5668\u5e76\u5b89\u88c5\u4e86Python\u89e3\u91ca\u5668\u540e\uff0c\u53ef\u4ee5\u5f00\u59cb\u7f16\u5199Python\u4ee3\u7801\u3002\u4ee5\u4e0b\u662f\u7f16\u5199\u5e76\u4fdd\u5b58Python\u811a\u672c\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p>\u6253\u5f00\u6587\u672c\u7f16\u8f91\u5668<\/p>\n<p>\u6253\u5f00\u9009\u62e9\u7684\u6587\u672c\u7f16\u8f91\u5668\uff0c\u5982Sublime Text\u3001Visual Studio Code\u6216PyCharm\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u7f16\u5199Python\u4ee3\u7801<\/p>\n<p>\u5728\u6587\u672c\u7f16\u8f91\u5668\u4e2d\u65b0\u5efa\u4e00\u4e2a\u6587\u4ef6\uff0c\u5e76\u7f16\u5199Python\u4ee3\u7801\u3002\u4f8b\u5982\uff0c\u7f16\u5199\u4e00\u4e2a\u7b80\u5355\u7684\u201cHello, World!\u201d\u7a0b\u5e8f\uff1a<\/p>\n<\/p>\n<\/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=\"3\">\n<li>\u4fdd\u5b58Python\u811a\u672c<\/p>\n<p>\u5c06\u6587\u4ef6\u4fdd\u5b58\u4e3a.py\u6269\u5c55\u540d\u7684\u6587\u4ef6\uff0c\u4f8b\u5982hello.py\u3002\u4fdd\u5b58\u8def\u5f84\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u8981\u9009\u62e9\u3002<\/li>\n<\/p>\n<\/ol>\n<p><p>\u4e94\u3001\u4f7f\u7528\u547d\u4ee4\u884c\u8fd0\u884cPython\u811a\u672c<\/p>\n<\/p>\n<p><p>\u7f16\u5199\u5e76\u4fdd\u5b58\u597dPython\u811a\u672c\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u8fd0\u884c\u811a\u672c\u3002\u4ee5\u4e0b\u662f\u8fd0\u884cPython\u811a\u672c\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p>\u6253\u5f00\u547d\u4ee4\u884c<\/p>\n<p>\u6253\u5f00\u547d\u4ee4\u884c\uff08Windows\u7528\u6237\u53ef\u4ee5\u4f7f\u7528cmd\u6216PowerShell\uff0cmacOS\u548cLinux\u7528\u6237\u53ef\u4ee5\u4f7f\u7528\u7ec8\u7aef\uff09\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u5bfc\u822a\u5230\u811a\u672c\u6240\u5728\u76ee\u5f55<\/p>\n<p>\u4f7f\u7528cd\u547d\u4ee4\u5bfc\u822a\u5230\u4fdd\u5b58Python\u811a\u672c\u7684\u76ee\u5f55\u3002\u4f8b\u5982\uff0c\u5982\u679c\u811a\u672c\u4fdd\u5b58\u5728C:\\Users\\Username\\Documents\u76ee\u5f55\u4e0b\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u5bfc\u822a\u5230\u8be5\u76ee\u5f55\uff1a<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><pre><code class=\"language-sh\">cd C:\\Users\\Username\\Documents<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li>\u8fd0\u884cPython\u811a\u672c<\/p>\n<p>\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u6765\u8fd0\u884cPython\u811a\u672c\uff1a<\/li>\n<\/p>\n<\/ol>\n<p><pre><code class=\"language-sh\">python hello.py<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u811a\u672c\u7f16\u5199\u6b63\u786e\uff0c\u5c06\u4f1a\u5728\u547d\u4ee4\u884c\u4e2d\u770b\u5230\u8f93\u51fa\u7ed3\u679c\u201cHello, World!\u201d\u3002<\/p>\n<\/p>\n<p><p>\u516d\u3001\u8c03\u8bd5\u548c\u4f18\u5316Python\u4ee3\u7801<\/p>\n<\/p>\n<p><p>\u7f16\u5199\u548c\u8fd0\u884cPython\u4ee3\u7801\u53ea\u662f\u5f00\u53d1\u8fc7\u7a0b\u7684\u4e00\u90e8\u5206\uff0c\u8c03\u8bd5\u548c\u4f18\u5316\u4ee3\u7801\u540c\u6837\u91cd\u8981\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u8c03\u8bd5\u548c\u4f18\u5316\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p>\u4f7f\u7528\u8c03\u8bd5\u5de5\u5177<\/p>\n<p>\u73b0\u4ee3\u6587\u672c\u7f16\u8f91\u5668\u548c\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u901a\u5e38\u5185\u7f6e\u8c03\u8bd5\u5de5\u5177\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u9010\u6b65\u6267\u884c\u4ee3\u7801\u3001\u8bbe\u7f6e\u65ad\u70b9\u3001\u67e5\u770b\u53d8\u91cf\u503c\u7b49\u3002\u901a\u8fc7\u8c03\u8bd5\u5de5\u5177\uff0c\u53ef\u4ee5\u66f4\u5bb9\u6613\u5730\u53d1\u73b0\u548c\u4fee\u590d\u4ee3\u7801\u4e2d\u7684\u95ee\u9898\u3002\u4f8b\u5982\uff0cVisual Studio Code\u548cPyCharm\u90fd\u5185\u7f6e\u4e86\u5f3a\u5927\u7684\u8c03\u8bd5\u5de5\u5177\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u4ee3\u7801Linting<\/p>\n<p>\u4ee3\u7801Linting\u662f\u4e00\u79cd\u9759\u6001\u4ee3\u7801\u5206\u6790\u5de5\u5177\uff0c\u53ef\u4ee5\u5728\u7f16\u5199\u4ee3\u7801\u65f6\u5b9e\u65f6\u68c0\u67e5\u4ee3\u7801\u4e2d\u7684\u9519\u8bef\u548c\u6f5c\u5728\u95ee\u9898\u3002\u901a\u8fc7\u5b89\u88c5Linting\u5de5\u5177\uff08\u5982Pylint\u3001Flake8\u7b49\uff09\uff0c\u53ef\u4ee5\u5728\u7f16\u5199\u4ee3\u7801\u65f6\u53ca\u65f6\u53d1\u73b0\u8bed\u6cd5\u9519\u8bef\u3001\u53d8\u91cf\u672a\u5b9a\u4e49\u7b49\u95ee\u9898\uff0c\u4ece\u800c\u63d0\u9ad8\u4ee3\u7801\u8d28\u91cf\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u4ee3\u7801\u683c\u5f0f\u5316<\/p>\n<p>\u7f16\u5199\u6574\u6d01\u3001\u6613\u8bfb\u7684\u4ee3\u7801\u662f\u4e00\u4e2a\u597d\u7684\u7f16\u7a0b\u4e60\u60ef\u3002\u901a\u8fc7\u4ee3\u7801\u683c\u5f0f\u5316\u5de5\u5177\uff08\u5982Black\u3001autopep8\u7b49\uff09\uff0c\u53ef\u4ee5\u81ea\u52a8\u5bf9\u4ee3\u7801\u8fdb\u884c\u683c\u5f0f\u5316\uff0c\u4f7f\u4ee3\u7801\u66f4\u52a0\u6574\u6d01\u3001\u6709\u6761\u7406\u3002\u683c\u5f0f\u5316\u540e\u7684\u4ee3\u7801\u4e0d\u4ec5\u6613\u4e8e\u7ef4\u62a4\uff0c\u8fd8\u80fd\u51cf\u5c11<a href=\"https:\/\/docs.pingcode.com\/code-review\" target=\"_blank\">\u4ee3\u7801\u5ba1\u67e5<\/a>\u65f6\u7684\u4e89\u8bae\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u6027\u80fd\u4f18\u5316<\/p>\n<p>\u5728\u7f16\u5199Python\u4ee3\u7801\u65f6\uff0c\u6027\u80fd\u4f18\u5316\u4e5f\u662f\u4e00\u4e2a\u91cd\u8981\u7684\u8003\u8651\u56e0\u7d20\u3002\u901a\u8fc7\u5206\u6790\u4ee3\u7801\u7684\u6267\u884c\u65f6\u95f4\u548c\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\uff0c\u53ef\u4ee5\u53d1\u73b0\u6027\u80fd\u74f6\u9888\u5e76\u8fdb\u884c\u4f18\u5316\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528timeit\u6a21\u5757\u6d4b\u91cf\u4ee3\u7801\u7684\u6267\u884c\u65f6\u95f4\uff0c\u4f7f\u7528cProfile\u6a21\u5757\u8fdb\u884c\u6027\u80fd\u5206\u6790\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e03\u3001\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6cd5<\/p>\n<\/p>\n<p><p>\u5728\u7f16\u5199\u548c\u8fd0\u884cPython\u4ee3\u7801\u7684\u8fc7\u7a0b\u4e2d\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u5e38\u89c1\u95ee\u9898\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p>Python\u672a\u5b89\u88c5\u6216\u672a\u6dfb\u52a0\u5230PATH<\/p>\n<p>\u5982\u679c\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884cPython\u811a\u672c\u65f6\u51fa\u73b0\u201cpython: command not found\u201d\u6216\u7c7b\u4f3c\u9519\u8bef\uff0c\u53ef\u80fd\u662f\u56e0\u4e3aPython\u672a\u5b89\u88c5\u6216\u672a\u6dfb\u52a0\u5230PATH\u3002\u5728\u5b89\u88c5Python\u65f6\uff0c\u786e\u4fdd\u52fe\u9009\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u6216\u8005\u624b\u52a8\u5c06Python\u5b89\u88c5\u8def\u5f84\u6dfb\u52a0\u5230\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u4e2d\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u8bed\u6cd5\u9519\u8bef<\/p>\n<p>\u8bed\u6cd5\u9519\u8bef\u662f\u7f16\u5199\u4ee3\u7801\u65f6\u5e38\u89c1\u7684\u95ee\u9898\u3002Python\u89e3\u91ca\u5668\u4f1a\u5728\u9047\u5230\u8bed\u6cd5\u9519\u8bef\u65f6\u63d0\u793a\u9519\u8bef\u4fe1\u606f\uff0c\u6839\u636e\u9519\u8bef\u4fe1\u606f\u53ef\u4ee5\u5b9a\u4f4d\u5e76\u4fee\u590d\u8bed\u6cd5\u9519\u8bef\u3002\u4f8b\u5982\uff0c\u5982\u679c\u5fd8\u8bb0\u5728print\u51fd\u6570\u540e\u52a0\u4e0a\u62ec\u53f7\uff0c\u89e3\u91ca\u5668\u4f1a\u63d0\u793a\u201cSyntaxError: Missing parentheses in call to &#39;print&#39;\u201d\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u6587\u4ef6\u8def\u5f84\u9519\u8bef<\/p>\n<p>\u5728\u8fd0\u884cPython\u811a\u672c\u65f6\uff0c\u5982\u679c\u51fa\u73b0\u201cFileNotFoundError\u201d\u9519\u8bef\uff0c\u53ef\u80fd\u662f\u56e0\u4e3a\u6587\u4ef6\u8def\u5f84\u9519\u8bef\u3002\u786e\u4fdd\u5728\u547d\u4ee4\u884c\u4e2d\u5bfc\u822a\u5230\u811a\u672c\u6240\u5728\u76ee\u5f55\uff0c\u6216\u8005\u4f7f\u7528\u5b8c\u6574\u8def\u5f84\u8fd0\u884c\u811a\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p>\u6a21\u5757\u672a\u5b89\u88c5<\/p>\n<p>\u5728\u5bfc\u5165\u5916\u90e8\u6a21\u5757\u65f6\uff0c\u5982\u679c\u51fa\u73b0\u201cModuleNotFoundError\u201d\u9519\u8bef\uff0c\u53ef\u80fd\u662f\u56e0\u4e3a\u6a21\u5757\u672a\u5b89\u88c5\u3002\u53ef\u4ee5\u4f7f\u7528pip\u5de5\u5177\u5b89\u88c5\u6240\u9700\u7684\u6a21\u5757\u3002\u4f8b\u5982\uff0c\u8981\u5b89\u88c5requests\u6a21\u5757\uff0c\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><pre><code class=\"language-sh\">pip install requests<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"5\">\n<li>\u8c03\u8bd5\u5de5\u5177\u65e0\u6cd5\u542f\u52a8<\/p>\n<p>\u5982\u679c\u5728\u4f7f\u7528\u8c03\u8bd5\u5de5\u5177\u65f6\u9047\u5230\u95ee\u9898\uff0c\u53ef\u80fd\u662f\u56e0\u4e3a\u8c03\u8bd5\u914d\u7f6e\u4e0d\u6b63\u786e\u3002\u68c0\u67e5\u8c03\u8bd5\u914d\u7f6e\u6587\u4ef6\uff08\u5982launch.json\uff09\u662f\u5426\u6b63\u786e\u914d\u7f6e\uff0c\u786e\u4fdd\u8c03\u8bd5\u5de5\u5177\u80fd\u591f\u6b63\u5e38\u542f\u52a8\u3002<\/li>\n<\/p>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\u548c\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5728\u6587\u672c\u7f16\u8f91\u5668\u4e2d\u7f16\u5199\u5e76\u8fd0\u884cPython\u4ee3\u7801\uff0c\u5e76\u4e14\u80fd\u591f\u6709\u6548\u5730\u8c03\u8bd5\u548c\u4f18\u5316\u4ee3\u7801\u3002\u9009\u62e9\u5408\u9002\u7684\u6587\u672c\u7f16\u8f91\u5668\u3001\u5b89\u88c5Python\u89e3\u91ca\u5668\u3001\u7f16\u5199\u5e76\u4fdd\u5b58Python\u811a\u672c\u3001\u4f7f\u7528\u547d\u4ee4\u884c\u8fd0\u884c\u811a\u672c\uff0c\u4ee5\u53ca\u8c03\u8bd5\u548c\u4f18\u5316\u4ee3\u7801\u662fPython\u5f00\u53d1\u7684\u91cd\u8981\u73af\u8282\u3002\u5e0c\u671b\u672c\u6587\u80fd\u591f\u5e2e\u52a9\u5230\u6b63\u5728\u5b66\u4e60Python\u7684\u5f00\u53d1\u8005\uff0c\u63d0\u9ad8\u7f16\u7a0b\u6548\u7387\u548c\u4ee3\u7801\u8d28\u91cf\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5728\u7f16\u8f91\u5668\u4e2d\u7f16\u5199Python\u4ee3\u7801\u540e\uff0c\u5e94\u8be5\u5982\u4f55\u8fd0\u884c\u5b83\uff1f<\/strong><br \/>\u8981\u8fd0\u884c\u7f16\u8f91\u5668\u4e2d\u7684Python\u4ee3\u7801\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177\u3002\u9996\u5148\uff0c\u786e\u4fdd\u60a8\u5df2\u7ecf\u5728\u7cfb\u7edf\u4e0a\u5b89\u88c5\u4e86Python\u3002\u6253\u5f00\u547d\u4ee4\u884c\u754c\u9762\uff0c\u5bfc\u822a\u5230\u5b58\u653e\u60a8\u4ee3\u7801\u7684\u6587\u4ef6\u5939\uff0c\u5e76\u8f93\u5165<code>python \u6587\u4ef6\u540d.py<\/code>\uff0c\u5176\u4e2d\u201c\u6587\u4ef6\u540d.py\u201d\u662f\u60a8\u7f16\u5199\u7684Python\u811a\u672c\u7684\u540d\u79f0\u3002\u6309\u4e0b\u56de\u8f66\u952e\u540e\uff0c\u60a8\u7684\u7a0b\u5e8f\u5c06\u5f00\u59cb\u6267\u884c\u3002<\/p>\n<p><strong>\u5982\u679c\u6211\u4e0d\u60f3\u4f7f\u7528\u547d\u4ee4\u884c\uff0c\u6709\u6ca1\u6709\u5176\u4ed6\u65b9\u5f0f\u53ef\u4ee5\u8fd0\u884cPython\u4ee3\u7801\uff1f<\/strong><br \/>\u5f53\u7136\u53ef\u4ee5\uff01\u8bb8\u591a\u73b0\u4ee3\u4ee3\u7801\u7f16\u8f91\u5668\u548c\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u5982PyCharm\u3001VSCode\u548cJupyter Notebook\u90fd\u63d0\u4f9b\u4e86\u4e00\u952e\u8fd0\u884c\u7684\u529f\u80fd\u3002\u60a8\u53ea\u9700\u6253\u5f00\u60a8\u7684Python\u6587\u4ef6\uff0c\u627e\u5230\u8fd0\u884c\u6309\u94ae\uff08\u901a\u5e38\u662f\u4e00\u4e2a\u7eff\u8272\u4e09\u89d2\u5f62\uff09\uff0c\u70b9\u51fb\u5b83\uff0c\u7a0b\u5e8f\u5c06\u81ea\u52a8\u6267\u884c\u5e76\u5728\u5185\u7f6e\u7ec8\u7aef\u4e2d\u663e\u793a\u7ed3\u679c\u3002<\/p>\n<p><strong>\u5982\u4f55\u786e\u4fdd\u6211\u7684Python\u4ee3\u7801\u53ef\u4ee5\u5728\u4e0d\u540c\u7684\u73af\u5883\u4e2d\u987a\u5229\u8fd0\u884c\uff1f<\/strong><br \/>\u4e3a\u4e86\u4fdd\u8bc1\u4ee3\u7801\u7684\u517c\u5bb9\u6027\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u865a\u62df\u73af\u5883\u3002\u865a\u62df\u73af\u5883\u5141\u8bb8\u60a8\u4e3a\u4e0d\u540c\u7684\u9879\u76ee\u521b\u5efa\u72ec\u7acb\u7684Python\u73af\u5883\uff0c\u907f\u514d\u4f9d\u8d56\u51b2\u7a81\u3002\u4f7f\u7528<code>venv<\/code>\u6a21\u5757\u521b\u5efa\u865a\u62df\u73af\u5883\u540e\uff0c\u60a8\u53ef\u4ee5\u5728\u5176\u4e2d\u5b89\u88c5\u7279\u5b9a\u7248\u672c\u7684\u5e93\uff0c\u5e76\u786e\u4fdd\u4ee3\u7801\u5728\u8be5\u73af\u5883\u4e0b\u6b63\u5e38\u8fd0\u884c\u3002\u6b64\u5916\uff0c\u5b9a\u671f\u6d4b\u8bd5\u548c\u4f7f\u7528\u7248\u672c\u63a7\u5236\u5de5\u5177\u5982Git\u4e5f\u662f\u786e\u4fdd\u4ee3\u7801\u53ef\u79fb\u690d\u6027\u7684\u597d\u65b9\u6cd5\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u4e00\u3001\u4f7f\u7528\u6587\u672c\u7f16\u8f91\u5668\u7f16\u5199Python\u4ee3\u7801\u5e76\u8fd0\u884c\u7684\u65b9\u6cd5\u6709\u5f88\u591a\u79cd\uff0c\u5305\u62ec\uff1a\u9009\u62e9\u5408\u9002\u7684\u6587\u672c\u7f16\u8f91\u5668\u3001\u5b89\u88c5Python\u89e3\u91ca\u5668 [&hellip;]","protected":false},"author":3,"featured_media":1083637,"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\/1083629"}],"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=1083629"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1083629\/revisions"}],"predecessor-version":[{"id":1083638,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1083629\/revisions\/1083638"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1083637"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1083629"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1083629"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1083629"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}