{"id":173451,"date":"2024-05-08T18:11:49","date_gmt":"2024-05-08T10:11:49","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/173451.html"},"modified":"2024-05-08T18:11:54","modified_gmt":"2024-05-08T10:11:54","slug":"vscode%e5%a6%82%e4%bd%95%e8%bf%90%e8%a1%8cpython","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/173451.html","title":{"rendered":"vscode\u5982\u4f55\u8fd0\u884cpython"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/27045358\/5c795780-ec6d-4060-ae2e-0f59ab2cbb8b.webp\" alt=\"vscode\u5982\u4f55\u8fd0\u884cpython\" \/><\/p>\n<p><p>\u8981\u5728VSCode\uff08Visual Studio Code\uff09\u4e2d\u8fd0\u884cPython\u7a0b\u5e8f\uff0c\u60a8\u9700\u8981\u5b8c\u6210\u51e0\u4e2a\u6b65\u9aa4\uff1a<strong>\u5b89\u88c5Python\u6269\u5c55\u3001\u914d\u7f6e\u89e3\u91ca\u5668\u3001\u5199\u4ee3\u7801\u3001\u8fd0\u884c\u4ee3\u7801<\/strong>\u3002\u786e\u4fdd\u60a8\u7684\u7cfb\u7edf\u4e0a\u5df2\u7ecf\u5b89\u88c5\u4e86Python\uff0c\u5e76\u5728VSCode\u4e2d\u5b89\u88c5\u4e86Python\u6269\u5c55\u3002\u4e00\u65e6\u8fd9\u4e9b\u90fd\u8bbe\u7f6e\u597d\uff0c\u60a8\u5c31\u53ef\u4ee5\u5728VSCode\u4e2d\u521b\u5efa\u6216\u6253\u5f00\u4e00\u4e2aPython\u6587\u4ef6\uff08\u4ee5.py\u7ed3\u5c3e\uff09\uff0c\u7f16\u5199\u4ee3\u7801\u5e76\u8fd0\u884c\u5b83\u3002\u901a\u8fc7\u6309\u4e0b<code>CTRL+F5<\/code>\u6216\u70b9\u51fbVSCode\u754c\u9762\u4e0a\u7684\u201c\u8fd0\u884c\u201d\u6309\u94ae\uff0c\u4ee3\u7801\u5c31\u4f1a\u5728VSCode\u96c6\u6210\u7684\u7ec8\u7aef\u4e2d\u6267\u884c\u3002<\/p>\n<\/p>\n<p><p>\u6211\u5c06\u5c55\u5f00\u8be6\u7ec6\u63cf\u8ff0<strong>\u5b89\u88c5Python\u6269\u5c55<\/strong>\uff0c\u5b83\u662f\u5728VSCode\u4e2d\u8fd0\u884cPython\u7684\u57fa\u672c\u6b65\u9aa4\u3002\u9996\u5148\uff0c\u6253\u5f00VSCode\uff0c\u7136\u540e\u8f6c\u5230\u4fa7\u8fb9\u680f\u4e0a\u7684\u6269\u5c55\u89c6\u56fe\uff0c\u53ef\u4ee5\u901a\u8fc7\u70b9\u51fb\u4fa7\u8fb9\u680f\u4e0a\u7684\u65b9\u5757\u56fe\u6807\u6216\u4f7f\u7528\u5feb\u6377\u952e<code>Ctrl+Shift+X<\/code>\u8bbf\u95ee\u3002\u5728\u6269\u5c55\u5e02\u573a\u4e2d\u641c\u7d22\u201cPython\u201d\uff0c\u627e\u5230\u7531Microsoft\u53d1\u5e03\u7684\u5b98\u65b9Python\u6269\u5c55\u3002\u70b9\u51fb\u5b89\u88c5\u3002\u8fd9\u4e2a\u6269\u5c55\u5c06\u4e3aVSCode\u63d0\u4f9b\u5f3a\u5927\u7684Python\u8bed\u8a00\u652f\u6301\uff0c\u5305\u62ec\u667a\u80fd\u611f\u77e5\u3001\u4ee3\u7801\u81ea\u52a8\u5b8c\u6210\u3001\u91cd\u6784\u3001\u8c03\u8bd5\u652f\u6301\u7b49\u3002<\/p>\n<\/p>\n<p><h2>\u4e00\u3001\u5b89\u88c5PYTHON\u4e0eVSCode<\/h2>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u786e\u4fdd\u60a8\u7684\u7535\u8111\u5df2\u5b89\u88c5Python\u3002\u60a8\u53ef\u4ee5\u8bbf\u95eePython\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u9002\u5408\u60a8\u64cd\u4f5c\u7cfb\u7edf\u7684Python\u7248\u672c\uff0c\u5e76\u6309\u6307\u5f15\u5b8c\u6210\u5b89\u88c5\u3002\u63a5\u7740\uff0c\u5982\u679c\u60a8\u8fd8\u6ca1\u6709VSCode\uff0c\u8bf7\u4eceVisual Studio Code\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u5b89\u88c5\u5b83\u3002<\/p>\n<\/p>\n<p><p>\u5b89\u88c5Python\u540e\uff0c\u60a8\u5e94\u8be5\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff0c\u4ee5\u4fbf\u80fd\u591f\u5728\u4efb\u4f55\u76ee\u5f55\u4e0b\u901a\u8fc7\u547d\u4ee4\u884c\u8fd0\u884cPython\u3002\u901a\u5e38\u5b89\u88c5\u7a0b\u5e8f\u4f1a\u4e3a\u60a8\u63d0\u4f9b\u6b64\u9009\u9879\u3002<\/p>\n<\/p>\n<p><h2>\u4e8c\u3001\u5b89\u88c5PYTHON\u6269\u5c55<\/h2>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210VSCode\u4e4b\u540e\uff0c\u9700\u8981\u5b89\u88c5Python\u6269\u5c55\u3002\u8fd9\u6837\u505a\u53ef\u4ee5\u901a\u8fc7VSCode\u5e02\u573a\u5feb\u901f\u5b8c\u6210\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00VSCode\u3002<\/li>\n<li>\u5bfb\u627e\u4fa7\u8fb9\u680f\u4e2d\u7684\u6269\u5c55\u56fe\u6807\u6216\u4f7f\u7528\u5feb\u6377\u952e<code>Ctrl+Shift+X<\/code>\u3002<\/li>\n<li>\u5728\u641c\u7d22\u680f\u8f93\u5165\u201cPython\u201d\u3002<\/li>\n<li>\u627e\u5230\u7531Microsoft\u53d1\u5e03\u7684Python\u6269\u5c55\uff0c\u70b9\u51fb\u201c\u5b89\u88c5\u201d\u3002<\/li>\n<\/ol>\n<p><p>\u8fd9\u4e2a\u6269\u5c55\u5c06\u4e3a\u60a8\u63d0\u4f9b\u8bed\u6cd5\u9ad8\u4eae\u3001\u4ee3\u7801\u63d0\u793a\u3001\u683c\u5f0f\u5316\u3001\u91cd\u6784\u5de5\u5177\u3001\u8c03\u8bd5\u7b49\u529f\u80fd\u3002<\/p>\n<\/p>\n<p><h2>\u4e09\u3001\u914d\u7f6ePYTHON\u89e3\u91ca\u5668<\/h2>\n<\/p>\n<p><p>\u5b89\u88c5\u6269\u5c55\u540e\uff0c\u60a8\u9700\u8981\u9009\u62e9\u4e00\u4e2aPython\u89e3\u91ca\u5668\u3002VSCode\u4f7f\u7528\u89e3\u91ca\u5668\u6765\u6267\u884cPython\u4ee3\u7801\u3001\u8c03\u8bd5\u7b49\u3002<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00VSCode\u3002<\/li>\n<li>\u6309<code>Ctrl+Shift+P<\/code>\u6253\u5f00\u547d\u4ee4\u9762\u677f\u3002<\/li>\n<li>\u8f93\u5165\u201cPython: Select Interpreter\u201d\u5e76\u9009\u62e9\u3002<\/li>\n<li>\u4ece\u5217\u8868\u4e2d\u9009\u62e9\u4e00\u4e2a\u5df2\u5b89\u88c5\u7684Python\u89e3\u91ca\u5668\u3002<\/li>\n<\/ol>\n<p><p><strong>\u786e\u4fdd\u9009\u62e9\u6b63\u786e\u7684\u89e3\u91ca\u5668<\/strong>\uff0c\u7279\u522b\u662f\u5f53\u60a8\u7684\u7cfb\u7edf\u4e2d\u5b89\u88c5\u4e86\u591a\u4e2aPython\u7248\u672c\u65f6\u3002<\/p>\n<\/p>\n<p><h2>\u56db\u3001\u5199\u4ee3\u7801<\/h2>\n<\/p>\n<p><p>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Python\u6587\u4ef6\uff0c\u53ef\u4ee5\u901a\u8fc7\u70b9\u51fb\u6587\u4ef6\u83dc\u5355\u4e2d\u7684\u201c\u65b0\u5efa\u6587\u4ef6\u201d\u6216\u4f7f\u7528\u5feb\u6377\u952e<code>Ctrl+N<\/code>\uff0c\u7136\u540e\u4fdd\u5b58\u4e3a.py\u6587\u4ef6\u3002\u5728\u8fd9\u4e2a\u65b0\u6587\u4ef6\u4e2d\uff0c\u60a8\u53ef\u4ee5\u5199Python\u4ee3\u7801\u3002VSCode\u63d0\u4f9b\u4e86\u4ee3\u7801\u63d0\u793a\u548c\u8865\u5168\u529f\u80fd\uff0c\u8fd9\u5c06\u6709\u52a9\u4e8e\u60a8\u66f4\u5feb\u5730\u7f16\u5199\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><h2>\u4e94\u3001\u8fd0\u884c\u4ee3\u7801<\/h2>\n<\/p>\n<p><p>\u4e00\u65e6\u4ee3\u7801\u5199\u597d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u8fd0\u884c\u5b83\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u5728VSCode\u4e2d\u6253\u5f00\u5e26\u6709Python\u4ee3\u7801\u7684.py\u6587\u4ef6\u3002<\/li>\n<li>\u60a8\u53ef\u4ee5\u901a\u8fc7\u70b9\u51fb\u53f3\u4e0a\u89d2\u7684\u201c\u8fd0\u884c\u201d\u6309\u94ae\u6216\u4f7f\u7528\u5feb\u6377\u952e<code>CTRL+F5<\/code>\u6765\u6267\u884c\u4ee3\u7801\u3002<\/li>\n<li>\u4ee3\u7801\u8fd0\u884c\u7684\u7ed3\u679c\u5c06\u663e\u793a\u5728\u96c6\u6210\u7ec8\u7aef\u4e2d\u3002<\/li>\n<\/ol>\n<p><p>\u8bf7\u6ce8\u610f\uff0c\u9996\u6b21\u8fd0\u884c\u7a0b\u5e8f\u65f6\uff0cVSCode\u53ef\u80fd\u4f1a\u63d0\u793a\u60a8\u5b89\u88c5\u4e00\u4e9b\u989d\u5916\u7684\u7ec4\u4ef6\uff0c\u6bd4\u5982linters\u6216debugger\u3002<\/p>\n<\/p>\n<p><h2>\u516d\u3001\u8c03\u8bd5PYTHON\u4ee3\u7801<\/h2>\n<\/p>\n<p><p>\u8c03\u8bd5\u662f\u7f16\u7a0b\u4e2d\u975e\u5e38\u91cd\u8981\u7684\u4e00\u90e8\u5206\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u60a8\u627e\u5230\u5e76\u4fee\u590d\u4ee3\u7801\u4e2d\u7684\u9519\u8bef\u3002VSCode\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5f3a\u5927\u7684\u8c03\u8bd5\u5668\u6765\u8c03\u8bd5Python\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u5728\u60a8\u7684Python\u4ee3\u7801\u4e2d\u8bbe\u7f6e\u65ad\u70b9\uff0c\u53ea\u9700\u70b9\u51fb\u4ee3\u7801\u5de6\u8fb9\u7684\u7a7a\u767d\u5904\u3002<\/li>\n<li>\u70b9\u51fb\u5de6\u8fb9\u8fb9\u680f\u4e2d\u7684\u201c\u8c03\u8bd5\u89c6\u56fe\u201d\u56fe\u6807\u6216\u6309<code>Ctrl+Shift+D<\/code>\u3002<\/li>\n<li>\u70b9\u51fb\u7eff\u8272\u7684\u5f00\u59cb\u8c03\u8bd5\u6309\u94ae\u6216\u6309<code>F5<\/code>\u952e\u3002<\/li>\n<li>\u8c03\u8bd5\u5668\u4f1a\u5728\u65ad\u70b9\u5904\u505c\u4e0b\u6765\uff0c\u8ba9\u60a8\u80fd\u591f\u76d1\u89c6\u53d8\u91cf\u503c\u3001\u6b65\u9aa4\u8fdb\u5165\u3001\u6b65\u9aa4\u7a7f\u8d8a\u3001\u6b65\u9aa4\u51fa\u6765\u548c\u7ee7\u7eed\u6267\u884c\u3002<\/li>\n<li>\u4f7f\u7528\u8c03\u8bd5\u9762\u677f\u4e0a\u7684\u6309\u94ae\u548c\u529f\u80fd\uff0c\u63a7\u5236\u8c03\u8bd5\u4f1a\u8bdd\u3002<\/li>\n<\/ol>\n<p><p>\u8c03\u8bd5\u8fc7\u7a0b\u4e2d\uff0c<strong>\u638c\u63e1\u8c03\u8bd5\u9762\u677f\u7684\u4f7f\u7528\u81f3\u5173\u91cd\u8981<\/strong>\uff0c\u8fd9\u53ef\u4ee5\u6709\u6548\u5730\u5e2e\u52a9\u60a8\u5ba1\u89c6\u4ee3\u7801\u884c\u4e3a\u3002<\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u6b65\u9aa4\uff0c\u5373\u4f7f\u662fPython\u521d\u5b66\u8005\u4e5f\u80fd\u591f\u5728VSCode\u4e2d\u8f7b\u677e\u5f00\u59cb\u7f16\u7a0b\u4e4b\u65c5\u3002\u968f\u7740\u7ecf\u9a8c\u7684\u79ef\u7d2f\uff0c\u60a8\u5c06\u80fd\u591f\u5229\u7528VSCode\u63d0\u4f9b\u7684\u66f4\u591a\u9ad8\u7ea7\u529f\u80fd\uff0c\u50cf\u662f\u4f7f\u7528\u865a\u62df\u73af\u5883\u3001\u5b89\u88c5\u548c\u7ba1\u7406\u7b2c\u4e09\u65b9\u5e93\u3001\u4f7f\u7528Git\u8fdb\u884c\u7248\u672c\u63a7\u5236\u7b49\uff0c\u8fd9\u4e9b\u90fd\u5c06\u8fdb\u4e00\u6b65\u63d0\u5347\u60a8\u7684\u5de5\u4f5c\u6548\u7387\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>1. \u5982\u4f55\u5728VSCode\u4e2d\u8bbe\u7f6ePython\u8fd0\u884c\u73af\u5883\uff1f<\/strong><\/p>\n<p>\u8981\u5728VSCode\u4e2d\u8fd0\u884cPython\u4ee3\u7801\uff0c\u9996\u5148\u9700\u8981\u914d\u7f6ePython\u8fd0\u884c\u73af\u5883\u3002\u9996\u5148\uff0c\u60a8\u9700\u8981\u5b89\u88c5Python\u89e3\u91ca\u5668\u3002\u7136\u540e\uff0c\u6253\u5f00VSCode\u5e76\u5b89\u88c5Python\u6269\u5c55\u3002\u4e00\u65e6\u5b89\u88c5\u5b8c\u6210\uff0c\u60a8\u53ef\u4ee5\u5728VSCode\u7684\u5e95\u90e8\u5de5\u5177\u680f\u4e2d\u9009\u62e9Python\u89e3\u91ca\u5668\uff0c\u6216\u4f7f\u7528\u547d\u4ee4\u9762\u677f\uff08Ctrl + Shift + P\uff09\u5e76\u8f93\u5165\u201cPython: Select Interpreter\u201d\u6765\u9009\u62e9\u60a8\u60f3\u8981\u4f7f\u7528\u7684Python\u89e3\u91ca\u5668\u3002<\/p>\n<p><strong>2. VSCode\u4e2d\u5982\u4f55\u8fd0\u884cPython\u4ee3\u7801\u6587\u4ef6\uff1f<\/strong><\/p>\n<p>\u5728VSCode\u4e2d\u8fd0\u884cPython\u4ee3\u7801\u6587\u4ef6\u975e\u5e38\u7b80\u5355\u3002\u53ea\u9700\u6253\u5f00\u60a8\u7684Python\u6587\u4ef6\uff0c\u7136\u540e\u6309\u4e0bF5\u952e\uff0c\u6216\u8005\u9009\u62e9VSCode\u83dc\u5355\u680f\u4e2d\u7684\u201c\u8c03\u8bd5\u201d&gt;\u201c\u542f\u52a8\u8c03\u8bd5\u201d\u9009\u9879\uff0c\u5373\u53ef\u542f\u52a8\u8c03\u8bd5\u5668\u3002\u4e00\u65e6\u8c03\u8bd5\u5668\u542f\u52a8\uff0c\u60a8\u53ef\u4ee5\u5355\u6b65\u6267\u884c\u4ee3\u7801\uff0c\u8bbe\u7f6e\u65ad\u70b9\uff0c\u67e5\u770b\u53d8\u91cf\u7684\u503c\u7b49\u3002<\/p>\n<p><strong>3. \u5982\u4f55\u8c03\u8bd5\u8fd0\u884cPython\u4ee3\u7801\u65f6\u51fa\u73b0\u7684\u9519\u8bef\uff1f<\/strong><\/p>\n<p>\u5728\u4f7f\u7528VSCode\u8fd0\u884cPython\u4ee3\u7801\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u9519\u8bef\u3002VSCode\u63d0\u4f9b\u4e86\u4e00\u4e9b\u8c03\u8bd5\u5de5\u5177\uff0c\u5e2e\u52a9\u60a8\u8bc6\u522b\u548c\u4fee\u590d\u8fd9\u4e9b\u9519\u8bef\u3002\u9996\u5148\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u65ad\u70b9\u6765\u6682\u505c\u4ee3\u7801\u7684\u6267\u884c\u5e76\u68c0\u67e5\u7a0b\u5e8f\u7684\u72b6\u6001\u3002\u5176\u6b21\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u201c\u8fd0\u884c\u5230\u5149\u6807\u5904\u201d\u529f\u80fd\uff0c\u4f7f\u7a0b\u5e8f\u5728\u7279\u5b9a\u4f4d\u7f6e\u505c\u4e0b\u6765\u3002\u6b64\u5916\uff0cVSCode\u8fd8\u63d0\u4f9b\u4e86\u5806\u6808\u8ddf\u8e2a\uff0c\u4ee5\u5e2e\u52a9\u60a8\u5b9a\u4f4d\u9519\u8bef\u53d1\u751f\u7684\u4f4d\u7f6e\u3002\u6700\u540e\uff0c\u60a8\u8fd8\u53ef\u4ee5\u901a\u8fc7\u67e5\u770b\u8f93\u51fa\u7a97\u53e3\u4e2d\u7684\u9519\u8bef\u6d88\u606f\u6765\u8c03\u8bd5\u4ee3\u7801\u4e2d\u7684\u95ee\u9898\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u5728VSCode\uff08Visual Studio Code\uff09\u4e2d\u8fd0\u884cPython\u7a0b\u5e8f\uff0c\u60a8\u9700\u8981\u5b8c\u6210\u51e0\u4e2a\u6b65\u9aa4\uff1a\u5b89\u88c5Pyt [&hellip;]","protected":false},"author":3,"featured_media":173458,"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\/173451"}],"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=173451"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/173451\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/173458"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=173451"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=173451"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=173451"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}