{"id":1035259,"date":"2024-12-31T11:57:20","date_gmt":"2024-12-31T03:57:20","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1035259.html"},"modified":"2024-12-31T11:57:23","modified_gmt":"2024-12-31T03:57:23","slug":"%e5%a6%82%e4%bd%95%e8%bf%90%e8%a1%8cpython3%e8%84%9a%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1035259.html","title":{"rendered":"\u5982\u4f55\u8fd0\u884cpython3\u811a\u672c"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2024\/12\/31ef2f2e-90a3-4522-ae08-0363145abd40.webp?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"\u5982\u4f55\u8fd0\u884cpython3\u811a\u672c\" \/><\/p>\n<p><p> <strong>\u8fd0\u884cPython3\u811a\u672c\u7684\u65b9\u6cd5\u5305\u62ec\u4f7f\u7528\u547d\u4ee4\u884c\u7ec8\u7aef\u3001\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u548c\u901a\u8fc7Python\u89e3\u91ca\u5668\u76f4\u63a5\u8fd0\u884c\u811a\u672c\u3002<\/strong> \u5176\u4e2d\uff0c\u4f7f\u7528\u547d\u4ee4\u884c\u7ec8\u7aef\u662f\u6700\u5e38\u89c1\u7684\u65b9\u6cd5\uff0c\u56e0\u4e3a\u5b83\u53ef\u4ee5\u5728\u5404\u79cd\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u4f7f\u7528\uff0c\u5982Windows\u3001Mac\u548cLinux\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5728\u4e0d\u540c\u73af\u5883\u4e0b\u8fd0\u884cPython3\u811a\u672c\uff0c\u5e76\u63d0\u4f9b\u4e00\u4e9b\u5b9e\u7528\u6280\u5de7\u548c\u5e38\u89c1\u95ee\u9898\u7684\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4f7f\u7528\u547d\u4ee4\u884c\u7ec8\u7aef\u8fd0\u884cPython3\u811a\u672c<\/p>\n<\/p>\n<p><p>\u5728\u547d\u4ee4\u884c\u7ec8\u7aef\u4e2d\u8fd0\u884cPython3\u811a\u672c\u662f\u6700\u57fa\u672c\u548c\u6700\u5e38\u89c1\u7684\u65b9\u6cd5\u3002\u65e0\u8bba\u662fWindows\u3001Mac\u8fd8\u662fLinux\uff0c\u7528\u6237\u90fd\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4\u884c\u7ec8\u7aef\u8f7b\u677e\u8fd0\u884cPython3\u811a\u672c\u3002<\/p>\n<\/p>\n<p><p>1.1\u3001Windows\u7cfb\u7edf<\/p>\n<\/p>\n<p><p>\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5728\u547d\u4ee4\u884c\u7ec8\u7aef\uff08cmd\uff09\u4e2d\u8fd0\u884cPython3\u811a\u672c\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u547d\u4ee4\u884c\u7ec8\u7aef\uff1a\u6309\u4e0b\u201cWin + R\u201d\u952e\uff0c\u8f93\u5165\u201ccmd\u201d\uff0c\u7136\u540e\u6309\u56de\u8f66\u952e\u3002<\/li>\n<li>\u5bfc\u822a\u5230\u5305\u542bPython3\u811a\u672c\u7684\u76ee\u5f55\uff1a\u4f7f\u7528\u201ccd\u201d\u547d\u4ee4\u8fdb\u5165\u5305\u542bPython3\u811a\u672c\u7684\u76ee\u5f55\u3002\u4f8b\u5982\uff0c\u8f93\u5165\u201ccd C:\\path\\to\\your\\script\u201d\u5e76\u6309\u56de\u8f66\u952e\u3002<\/li>\n<li>\u8fd0\u884cPython3\u811a\u672c\uff1a\u8f93\u5165\u201cpython script_name.py\u201d\u5e76\u6309\u56de\u8f66\u952e\uff0c\u5176\u4e2d\u201cscript_name.py\u201d\u662f\u4f60\u7684Python3\u811a\u672c\u7684\u540d\u79f0\u3002\u5982\u679c\u4f60\u7684\u7cfb\u7edf\u4e2d\u5b89\u88c5\u4e86\u591a\u4e2aPython\u7248\u672c\uff0c\u53ef\u4ee5\u4f7f\u7528\u201cpython3 script_name.py\u201d\u6765\u786e\u4fdd\u8fd0\u884c\u7684\u662fPython3\u3002<\/li>\n<\/ol>\n<p><p>1.2\u3001Mac\u548cLinux\u7cfb\u7edf<\/p>\n<\/p>\n<p><p>\u5728Mac\u548cLinux\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884cPython3\u811a\u672c\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u7ec8\u7aef\uff1a\u5728Mac\u4e0a\uff0c\u53ef\u4ee5\u6309\u4e0b\u201cCommand + \u7a7a\u683c\u952e\u201d\u5e76\u8f93\u5165\u201cTerminal\u201d\uff0c\u7136\u540e\u6309\u56de\u8f66\u952e\u3002\u5728Linux\u4e0a\uff0c\u901a\u5e38\u53ef\u4ee5\u901a\u8fc7\u5e94\u7528\u7a0b\u5e8f\u83dc\u5355\u6216\u5feb\u6377\u952e\u6253\u5f00\u7ec8\u7aef\u3002<\/li>\n<li>\u5bfc\u822a\u5230\u5305\u542bPython3\u811a\u672c\u7684\u76ee\u5f55\uff1a\u4f7f\u7528\u201ccd\u201d\u547d\u4ee4\u8fdb\u5165\u5305\u542bPython3\u811a\u672c\u7684\u76ee\u5f55\u3002\u4f8b\u5982\uff0c\u8f93\u5165\u201ccd \/path\/to\/your\/script\u201d\u5e76\u6309\u56de\u8f66\u952e\u3002<\/li>\n<li>\u8fd0\u884cPython3\u811a\u672c\uff1a\u8f93\u5165\u201cpython3 script_name.py\u201d\u5e76\u6309\u56de\u8f66\u952e\uff0c\u5176\u4e2d\u201cscript_name.py\u201d\u662f\u4f60\u7684Python3\u811a\u672c\u7684\u540d\u79f0\u3002\u6ce8\u610f\uff0c\u5728Linux\u7cfb\u7edf\u4e2d\uff0c\u901a\u5e38\u4f7f\u7528\u201cpython3\u201d\u547d\u4ee4\u6765\u8fd0\u884cPython3\u811a\u672c\uff0c\u4ee5\u533a\u5206Python2\u548cPython3\u3002<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u8fd0\u884cPython3\u811a\u672c<\/p>\n<\/p>\n<p><p>\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u662f\u8fd0\u884c\u548c\u8c03\u8bd5Python3\u811a\u672c\u7684\u53e6\u4e00\u79cd\u5e38\u89c1\u65b9\u6cd5\u3002IDE\u901a\u5e38\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u529f\u80fd\uff0c\u5982\u4ee3\u7801\u7f16\u8f91\u3001\u8c03\u8bd5\u3001\u81ea\u52a8\u8865\u5168\u7b49\uff0c\u53ef\u4ee5\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u3002\u4ee5\u4e0b\u662f\u51e0\u79cd\u5e38\u89c1\u7684Python IDE\uff1a<\/p>\n<\/p>\n<p><p>2.1\u3001PyCharm<\/p>\n<\/p>\n<p><p>PyCharm\u662fJetBr<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>ns\u516c\u53f8\u5f00\u53d1\u7684\u4e00\u6b3e\u529f\u80fd\u5f3a\u5927\u7684Python IDE\uff0c\u5e7f\u53d7\u5f00\u53d1\u8005\u6b22\u8fce\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528PyCharm\u8fd0\u884cPython3\u811a\u672c\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u5b89\u88c5PyCharm\uff1a\u8bbf\u95eePyCharm\u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/www.jetbrains.com\/pycharm\/%EF%BC%89%EF%BC%8C%E4%B8%8B%E8%BD%BD%E5%B9%B6%E5%AE%89%E8%A3%85%E9%80%82%E5%90%88%E4%BD%A0%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E7%9A%84%E7%89%88%E6%9C%AC%E3%80%82\">https:\/\/www.jetbrains.com\/pycharm\/\uff09\uff0c\u4e0b\u8f7d\u5e76\u5b89\u88c5\u9002\u5408\u4f60\u64cd\u4f5c\u7cfb\u7edf\u7684\u7248\u672c\u3002<\/a><\/li>\n<li>\u521b\u5efa\u6216\u6253\u5f00\u9879\u76ee\uff1a\u542f\u52a8PyCharm\uff0c\u70b9\u51fb\u201cNew Project\u201d\u521b\u5efa\u4e00\u4e2a\u65b0\u9879\u76ee\uff0c\u6216\u70b9\u51fb\u201cOpen\u201d\u6253\u5f00\u4e00\u4e2a\u5df2\u6709\u9879\u76ee\u3002<\/li>\n<li>\u521b\u5efa\u6216\u6253\u5f00Python3\u811a\u672c\uff1a\u5728\u9879\u76ee\u4e2d\u53f3\u952e\u70b9\u51fb\u6587\u4ef6\u5939\uff0c\u9009\u62e9\u201cNew\u201d-&gt;\u201cPython File\u201d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Python3\u811a\u672c\uff0c\u6216\u76f4\u63a5\u53cc\u51fb\u5df2\u6709\u7684Python3\u811a\u672c\u6253\u5f00\u3002<\/li>\n<li>\u8fd0\u884cPython3\u811a\u672c\uff1a\u5728\u7f16\u8f91\u5668\u4e2d\u53f3\u952e\u70b9\u51fb\u811a\u672c\u6587\u4ef6\uff0c\u9009\u62e9\u201cRun &#39;script_name&#39;\u201d\uff0c\u5176\u4e2d\u201cscript_name\u201d\u662f\u4f60\u7684Python3\u811a\u672c\u7684\u540d\u79f0\u3002\u6216\u8005\uff0c\u4f60\u4e5f\u53ef\u4ee5\u70b9\u51fb\u5de5\u5177\u680f\u4e0a\u7684\u7eff\u8272\u7bad\u5934\u6309\u94ae\u8fd0\u884c\u811a\u672c\u3002<\/li>\n<\/ol>\n<p><p>2.2\u3001Visual Studio Code<\/p>\n<\/p>\n<p><p>Visual Studio Code\uff08VS Code\uff09\u662f\u7531\u5fae\u8f6f\u5f00\u53d1\u7684\u4e00\u6b3e\u5f00\u6e90\u4ee3\u7801\u7f16\u8f91\u5668\uff0c\u652f\u6301\u591a\u79cd\u7f16\u7a0b\u8bed\u8a00\uff0c\u5305\u62ecPython\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528VS Code\u8fd0\u884cPython3\u811a\u672c\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u5b89\u88c5VS Code\uff1a\u8bbf\u95eeVisual Studio Code\u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/code.visualstudio.com\/%EF%BC%89%EF%BC%8C%E4%B8%8B%E8%BD%BD%E5%B9%B6%E5%AE%89%E8%A3%85%E9%80%82%E5%90%88%E4%BD%A0%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E7%9A%84%E7%89%88%E6%9C%AC%E3%80%82\">https:\/\/code.visualstudio.com\/\uff09\uff0c\u4e0b\u8f7d\u5e76\u5b89\u88c5\u9002\u5408\u4f60\u64cd\u4f5c\u7cfb\u7edf\u7684\u7248\u672c\u3002<\/a><\/li>\n<li>\u5b89\u88c5Python\u6269\u5c55\uff1a\u542f\u52a8VS Code\uff0c\u70b9\u51fb\u5de6\u4fa7\u6d3b\u52a8\u680f\u4e2d\u7684\u201cExtensions\u201d\u56fe\u6807\uff0c\u641c\u7d22\u201cPython\u201d\uff0c\u7136\u540e\u70b9\u51fb\u201cInstall\u201d\u5b89\u88c5Python\u6269\u5c55\u3002<\/li>\n<li>\u6253\u5f00\u5de5\u4f5c\u533a\uff1a\u70b9\u51fb\u201cFile\u201d-&gt;\u201cOpen Folder\u201d\uff0c\u9009\u62e9\u5305\u542bPython3\u811a\u672c\u7684\u6587\u4ef6\u5939\u4f5c\u4e3a\u5de5\u4f5c\u533a\u3002<\/li>\n<li>\u521b\u5efa\u6216\u6253\u5f00Python3\u811a\u672c\uff1a\u5728\u5de5\u4f5c\u533a\u4e2d\u53f3\u952e\u70b9\u51fb\u6587\u4ef6\u5939\uff0c\u9009\u62e9\u201cNew File\u201d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Python3\u811a\u672c\uff0c\u6216\u76f4\u63a5\u53cc\u51fb\u5df2\u6709\u7684Python3\u811a\u672c\u6253\u5f00\u3002<\/li>\n<li>\u8fd0\u884cPython3\u811a\u672c\uff1a\u5728\u7f16\u8f91\u5668\u4e2d\u53f3\u952e\u70b9\u51fb\u811a\u672c\u6587\u4ef6\uff0c\u9009\u62e9\u201cRun Python File in Terminal\u201d\u3002\u6216\u8005\uff0c\u4f60\u4e5f\u53ef\u4ee5\u6309\u4e0b\u201cCtrl + Shift + P\u201d\u6253\u5f00\u547d\u4ee4\u9762\u677f\uff0c\u8f93\u5165\u201cRun Python File in Terminal\u201d\u5e76\u6309\u56de\u8f66\u952e\u3002<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u901a\u8fc7Python\u89e3\u91ca\u5668\u76f4\u63a5\u8fd0\u884c\u811a\u672c<\/p>\n<\/p>\n<p><p>\u9664\u4e86\u5728\u547d\u4ee4\u884c\u7ec8\u7aef\u548cIDE\u4e2d\u8fd0\u884cPython3\u811a\u672c\u5916\uff0c\u8fd8\u53ef\u4ee5\u901a\u8fc7Python\u89e3\u91ca\u5668\u76f4\u63a5\u8fd0\u884c\u811a\u672c\u3002\u8fd9\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u9700\u8981\u5feb\u901f\u6d4b\u8bd5\u548c\u8c03\u8bd5\u4ee3\u7801\u7684\u60c5\u51b5\u3002<\/p>\n<\/p>\n<p><p>3.1\u3001\u4ea4\u4e92\u5f0f\u6a21\u5f0f<\/p>\n<\/p>\n<p><p>Python\u89e3\u91ca\u5668\u63d0\u4f9b\u4e86\u4ea4\u4e92\u5f0f\u6a21\u5f0f\uff0c\u53ef\u4ee5\u76f4\u63a5\u5728\u547d\u4ee4\u884c\u7ec8\u7aef\u4e2d\u8f93\u5165\u548c\u6267\u884cPython\u4ee3\u7801\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528\u4ea4\u4e92\u5f0f\u6a21\u5f0f\u8fd0\u884cPython\u4ee3\u7801\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u547d\u4ee4\u884c\u7ec8\u7aef\uff1a\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u6309\u4e0b\u201cWin + R\u201d\u952e\uff0c\u8f93\u5165\u201ccmd\u201d\uff0c\u7136\u540e\u6309\u56de\u8f66\u952e\u3002\u5728Mac\u548cLinux\u7cfb\u7edf\u4e2d\uff0c\u6253\u5f00\u7ec8\u7aef\u3002<\/li>\n<li>\u542f\u52a8Python\u89e3\u91ca\u5668\uff1a\u8f93\u5165\u201cpython\u201d\u6216\u201cpython3\u201d\u5e76\u6309\u56de\u8f66\u952e\uff0c\u542f\u52a8Python\u89e3\u91ca\u5668\u3002\u4f60\u4f1a\u770b\u5230\u7c7b\u4f3c\u201c&gt;&gt;&gt;\u201d\u7684\u63d0\u793a\u7b26\uff0c\u8fd9\u8868\u793a\u4f60\u5df2\u7ecf\u8fdb\u5165\u4e86Python\u4ea4\u4e92\u5f0f\u6a21\u5f0f\u3002<\/li>\n<li>\u8f93\u5165\u5e76\u6267\u884cPython\u4ee3\u7801\uff1a\u5728\u63d0\u793a\u7b26\u4e0b\u8f93\u5165Python\u4ee3\u7801\u5e76\u6309\u56de\u8f66\u952e\uff0cPython\u89e3\u91ca\u5668\u4f1a\u7acb\u5373\u6267\u884c\u5e76\u663e\u793a\u7ed3\u679c\u3002\u4f8b\u5982\uff0c\u8f93\u5165\u201cprint(&#39;Hello, World!&#39;)\u201d\u5e76\u6309\u56de\u8f66\u952e\uff0c\u4f60\u4f1a\u770b\u5230\u8f93\u51fa\u7ed3\u679c\u201cHello, World!\u201d\u3002<\/li>\n<\/ol>\n<p><p>3.2\u3001\u811a\u672c\u6a21\u5f0f<\/p>\n<\/p>\n<p><p>\u9664\u4e86\u4ea4\u4e92\u5f0f\u6a21\u5f0f\u5916\uff0cPython\u89e3\u91ca\u5668\u8fd8\u53ef\u4ee5\u76f4\u63a5\u8fd0\u884c\u4fdd\u5b58\u4e3a\u6587\u4ef6\u7684Python3\u811a\u672c\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528\u811a\u672c\u6a21\u5f0f\u8fd0\u884cPython3\u811a\u672c\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u547d\u4ee4\u884c\u7ec8\u7aef\uff1a\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u6309\u4e0b\u201cWin + R\u201d\u952e\uff0c\u8f93\u5165\u201ccmd\u201d\uff0c\u7136\u540e\u6309\u56de\u8f66\u952e\u3002\u5728Mac\u548cLinux\u7cfb\u7edf\u4e2d\uff0c\u6253\u5f00\u7ec8\u7aef\u3002<\/li>\n<li>\u5bfc\u822a\u5230\u5305\u542bPython3\u811a\u672c\u7684\u76ee\u5f55\uff1a\u4f7f\u7528\u201ccd\u201d\u547d\u4ee4\u8fdb\u5165\u5305\u542bPython3\u811a\u672c\u7684\u76ee\u5f55\u3002\u4f8b\u5982\uff0c\u8f93\u5165\u201ccd C:\\path\\to\\your\\script\u201d\u5e76\u6309\u56de\u8f66\u952e\u3002<\/li>\n<li>\u8fd0\u884cPython3\u811a\u672c\uff1a\u8f93\u5165\u201cpython script_name.py\u201d\u6216\u201cpython3 script_name.py\u201d\u5e76\u6309\u56de\u8f66\u952e\uff0c\u5176\u4e2d\u201cscript_name.py\u201d\u662f\u4f60\u7684Python3\u811a\u672c\u7684\u540d\u79f0\u3002<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u8fd0\u884cPython3\u811a\u672c\u65f6\u7684\u5e38\u89c1\u95ee\u9898\u548c\u89e3\u51b3\u65b9\u6cd5<\/p>\n<\/p>\n<p><p>\u5728\u8fd0\u884cPython3\u811a\u672c\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u5e38\u89c1\u95ee\u9898\u3002\u4ee5\u4e0b\u662f\u51e0\u79cd\u5e38\u89c1\u95ee\u9898\u53ca\u5176\u89e3\u51b3\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<p><p>4.1\u3001\u627e\u4e0d\u5230Python\u89e3\u91ca\u5668<\/p>\n<\/p>\n<p><p>\u5982\u679c\u5728\u547d\u4ee4\u884c\u7ec8\u7aef\u4e2d\u8f93\u5165\u201cpython\u201d\u6216\u201cpython3\u201d\u540e\u663e\u793a\u201c\u627e\u4e0d\u5230\u547d\u4ee4\u201d\u6216\u7c7b\u4f3c\u9519\u8bef\u4fe1\u606f\uff0c\u53ef\u80fd\u662f\u56e0\u4e3aPython\u89e3\u91ca\u5668\u672a\u6b63\u786e\u5b89\u88c5\u6216\u672a\u6dfb\u52a0\u5230\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u4e2d\u3002\u89e3\u51b3\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u786e\u4fdd\u5df2\u5b89\u88c5Python3\uff1a\u8bbf\u95eePython\u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/www.python.org\/%EF%BC%89%EF%BC%8C%E4%B8%8B%E8%BD%BD%E5%B9%B6%E5%AE%89%E8%A3%85%E6%9C%80%E6%96%B0%E7%89%88%E6%9C%AC%E7%9A%84Python3%E3%80%82\">https:\/\/www.python.org\/\uff09\uff0c\u4e0b\u8f7d\u5e76\u5b89\u88c5\u6700\u65b0\u7248\u672c\u7684Python3\u3002<\/a><\/li>\n<li>\u6dfb\u52a0Python\u89e3\u91ca\u5668\u5230\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\uff1a\u5728Windows\u7cfb\u7edf\u4e2d\uff0c\u53f3\u952e\u70b9\u51fb\u201c\u6b64\u7535\u8111\u201d-&gt;\u201c\u5c5e\u6027\u201d-&gt;\u201c\u9ad8\u7ea7\u7cfb\u7edf\u8bbe\u7f6e\u201d-&gt;\u201c\u73af\u5883\u53d8\u91cf\u201d\uff0c\u627e\u5230\u201cPath\u201d\u53d8\u91cf\u5e76\u6dfb\u52a0Python\u89e3\u91ca\u5668\u7684\u5b89\u88c5\u8def\u5f84\u3002\u5728Mac\u548cLinux\u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u5728\u7ec8\u7aef\u4e2d\u7f16\u8f91\u201c.bashrc\u201d\u6216\u201c.zshrc\u201d\u6587\u4ef6\uff0c\u6dfb\u52a0\u201cexport PATH=$PATH:\/path\/to\/python3\u201d\u3002<\/li>\n<\/ol>\n<p><p>4.2\u3001\u811a\u672c\u6587\u4ef6\u7f16\u7801\u95ee\u9898<\/p>\n<\/p>\n<p><p>\u6709\u65f6\u5728\u8fd0\u884cPython3\u811a\u672c\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u7f16\u7801\u95ee\u9898\uff0c\u7279\u522b\u662f\u6d89\u53ca\u975eASCII\u5b57\u7b26\u65f6\u3002\u89e3\u51b3\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u786e\u4fdd\u811a\u672c\u6587\u4ef6\u4f7f\u7528UTF-8\u7f16\u7801\uff1a\u5728\u7f16\u8f91\u5668\u4e2d\u6253\u5f00\u811a\u672c\u6587\u4ef6\uff0c\u786e\u8ba4\u6587\u4ef6\u7f16\u7801\u4e3aUTF-8\u3002\u5982\u679c\u4e0d\u662f\uff0c\u53ef\u4ee5\u5c06\u6587\u4ef6\u91cd\u65b0\u4fdd\u5b58\u4e3aUTF-8\u7f16\u7801\u3002<\/li>\n<li>\u5728\u811a\u672c\u6587\u4ef6\u5f00\u5934\u6dfb\u52a0\u7f16\u7801\u58f0\u660e\uff1a\u5728Python3\u811a\u672c\u6587\u4ef6\u7684\u7b2c\u4e00\u884c\u6dfb\u52a0\u201c# &#8211;<em>&#8211; coding: utf-8 &#8211;<\/em>-\u201d\uff0c\u58f0\u660e\u6587\u4ef6\u7f16\u7801\u4e3aUTF-8\u3002<\/li>\n<\/ol>\n<p><p>4.3\u3001\u4f9d\u8d56\u5305\u672a\u5b89\u88c5<\/p>\n<\/p>\n<p><p>\u5728\u8fd0\u884cPython3\u811a\u672c\u65f6\uff0c\u5982\u679c\u811a\u672c\u4f9d\u8d56\u7684\u7b2c\u4e09\u65b9\u5305\u672a\u5b89\u88c5\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u201cModuleNotFoundError\u201d\u6216\u7c7b\u4f3c\u9519\u8bef\u4fe1\u606f\u3002\u89e3\u51b3\u65b9\u6cd5\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u4f7f\u7528pip\u5b89\u88c5\u4f9d\u8d56\u5305\uff1a\u5728\u547d\u4ee4\u884c\u7ec8\u7aef\u4e2d\u8f93\u5165\u201cpip install package_name\u201d\u6216\u201cpip3 install package_name\u201d\u5e76\u6309\u56de\u8f66\u952e\uff0c\u5176\u4e2d\u201cpackage_name\u201d\u662f\u4f9d\u8d56\u5305\u7684\u540d\u79f0\u3002\u4f8b\u5982\uff0c\u8f93\u5165\u201cpip install requests\u201d\u5b89\u88c5\u201crequests\u201d\u5305\u3002<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u65b9\u6cd5\u548c\u6280\u5de7\uff0c\u4f60\u53ef\u4ee5\u5728\u4e0d\u540c\u73af\u5883\u4e0b\u8f7b\u677e\u8fd0\u884cPython3\u811a\u672c\uff0c\u5e76\u89e3\u51b3\u5e38\u89c1\u95ee\u9898\u3002\u65e0\u8bba\u662f\u521d\u5b66\u8005\u8fd8\u662f\u6709\u7ecf\u9a8c\u7684\u5f00\u53d1\u8005\uff0c\u90fd\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u9009\u62e9\u6700\u9002\u5408\u7684\u8fd0\u884c\u65b9\u5f0f\uff0c\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u8fd0\u884cPython3\u811a\u672c\uff1f<\/strong><br \/>\u5728Windows\u3001macOS\u548cLinux\u7b49\u4e0d\u540c\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u8fd0\u884cPython3\u811a\u672c\u7684\u65b9\u6cd5\u7565\u6709\u4e0d\u540c\u3002\u5bf9\u4e8eWindows\u7528\u6237\uff0c\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u63d0\u793a\u7b26\uff08CMD\uff09\u6216PowerShell\uff0c\u8f93\u5165<code>python your_script.py<\/code>\u6216<code>python3 your_script.py<\/code>\u3002\u5728macOS\u548cLinux\u4e2d\uff0c\u6253\u5f00\u7ec8\u7aef\u5e76\u4f7f\u7528\u76f8\u540c\u7684\u547d\u4ee4\u8fd0\u884c\u811a\u672c\u3002\u786e\u4fdd\u5728\u8fd0\u884c\u4e4b\u524d\u5df2\u7ecf\u6b63\u786e\u5b89\u88c5\u4e86Python3\uff0c\u5e76\u5c06\u5176\u6dfb\u52a0\u5230\u7cfb\u7edf\u7684\u73af\u5883\u53d8\u91cf\u4e2d\u3002<\/p>\n<p><strong>\u5982\u679c\u6211\u7684Python3\u811a\u672c\u5305\u542b\u9519\u8bef\uff0c\u5982\u4f55\u8c03\u8bd5\u5b83\uff1f<\/strong><br \/>\u8c03\u8bd5Python3\u811a\u672c\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528Python\u5185\u7f6e\u7684\u8c03\u8bd5\u5de5\u5177\uff0c\u5982<code>pdb<\/code>\u3002\u901a\u8fc7\u5728\u4ee3\u7801\u4e2d\u6dfb\u52a0<code>import pdb; pdb.set_trace()<\/code>\u53ef\u4ee5\u8bbe\u7f6e\u65ad\u70b9\uff0c\u65b9\u4fbf\u9010\u884c\u68c0\u67e5\u4ee3\u7801\u6267\u884c\u60c5\u51b5\u3002\u6b64\u5916\uff0c\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u5982PyCharm\u6216VSCode\uff0c\u5b83\u4eec\u90fd\u63d0\u4f9b\u4e86\u53ef\u89c6\u5316\u7684\u8c03\u8bd5\u5de5\u5177\uff0c\u53ef\u4ee5\u5e2e\u52a9\u5feb\u901f\u5b9a\u4f4d\u95ee\u9898\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Python3\u811a\u672c\u4e2d\u5904\u7406\u5916\u90e8\u5e93\uff1f<\/strong><br \/>\u5728Python3\u811a\u672c\u4e2d\u4f7f\u7528\u5916\u90e8\u5e93\u4e4b\u524d\uff0c\u9700\u8981\u786e\u4fdd\u5df2\u7ecf\u5b89\u88c5\u4e86\u76f8\u5e94\u7684\u5e93\u3002\u53ef\u4ee5\u4f7f\u7528<code>pip install library_name<\/code>\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\u3002\u5b89\u88c5\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7<code>import library_name<\/code>\u8bed\u53e5\u5728\u811a\u672c\u4e2d\u5f15\u5165\u8be5\u5e93\u3002\u5982\u679c\u9700\u8981\u4f7f\u7528\u7279\u5b9a\u7248\u672c\u7684\u5e93\uff0c\u53ef\u4ee5\u5728\u5b89\u88c5\u65f6\u6307\u5b9a\u7248\u672c\u53f7\uff0c\u5982<code>pip install library_name==version_number<\/code>\u3002\u8fd9\u6837\u53ef\u4ee5\u786e\u4fdd\u811a\u672c\u5728\u4e0d\u540c\u73af\u5883\u4e2d\u4fdd\u6301\u4e00\u81f4\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8fd0\u884cPython3\u811a\u672c\u7684\u65b9\u6cd5\u5305\u62ec\u4f7f\u7528\u547d\u4ee4\u884c\u7ec8\u7aef\u3001\u4f7f\u7528\u96c6\u6210\u5f00\u53d1\u73af\u5883\uff08IDE\uff09\u548c\u901a\u8fc7Python\u89e3\u91ca\u5668\u76f4\u63a5\u8fd0\u884c\u811a\u672c [&hellip;]","protected":false},"author":3,"featured_media":1035270,"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\/1035259"}],"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=1035259"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1035259\/revisions"}],"predecessor-version":[{"id":1035272,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1035259\/revisions\/1035272"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1035270"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1035259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1035259"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1035259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}