{"id":947275,"date":"2024-12-26T23:50:07","date_gmt":"2024-12-26T15:50:07","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/947275.html"},"modified":"2024-12-26T23:50:09","modified_gmt":"2024-12-26T15:50:09","slug":"vsc%e5%a6%82%e4%bd%95%e5%af%bc%e5%85%a5python","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/947275.html","title":{"rendered":"vsc\u5982\u4f55\u5bfc\u5165python"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25083115\/c29c8a06-e035-4138-9fac-25cafee26d07.webp\" alt=\"vsc\u5982\u4f55\u5bfc\u5165python\" \/><\/p>\n<p><p> <strong>\u5728VSCode\u4e2d\u5bfc\u5165Python\u7684\u6b65\u9aa4\u5305\u62ec\uff1a\u5b89\u88c5Python\u3001\u5b89\u88c5VSCode\u3001\u5b89\u88c5Python\u6269\u5c55\u3001\u914d\u7f6ePython\u89e3\u91ca\u5668\u3001\u521b\u5efaPython\u6587\u4ef6\u3001\u8fd0\u884c\u548c\u8c03\u8bd5Python\u4ee3\u7801<\/strong>\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5728Visual Studio Code\uff08VSCode\uff09\u4e2d\u5bfc\u5165\u5e76\u4f7f\u7528Python\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u5b89\u88c5Python<\/p>\n<\/p>\n<p><p>\u5728\u4f7f\u7528VSCode\u8fdb\u884cPython\u7f16\u7a0b\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u5728\u7cfb\u7edf\u4e2d\u5b89\u88c5Python\u3002Python\u662f\u4e00\u79cd\u5e7f\u6cdb\u4f7f\u7528\u7684\u7f16\u7a0b\u8bed\u8a00\uff0c\u9002\u7528\u4e8e\u591a\u79cd\u5e94\u7528\u573a\u666f\u3002\u4ee5\u4e0b\u662f\u5b89\u88c5Python\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4e0b\u8f7dPython<\/strong>\uff1a\u8bbf\u95eePython\u7684\u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/www.python.org\/%EF%BC%89%EF%BC%8C%E4%BB%8E%E4%B8%8B%E8%BD%BD%E9%A1%B5%E9%9D%A2%E9%80%89%E6%8B%A9%E9%80%82%E5%90%88%E4%BD%A0%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E7%9A%84Python%E7%89%88%E6%9C%AC%E3%80%82%E5%AF%B9%E4%BA%8E%E5%A4%A7%E5%A4%9A%E6%95%B0%E7%94%A8%E6%88%B7%EF%BC%8C%E4%B8%8B%E8%BD%BD%E7%A8%B3%E5%AE%9A%E7%9A%84%E7%89%88%E6%9C%AC%E5%8D%B3%E5%8F%AF%EF%BC%8C%E6%AF%94%E5%A6%82Python\">https:\/\/www.python.org\/\uff09\uff0c\u4ece\u4e0b\u8f7d\u9875\u9762\u9009\u62e9\u9002\u5408\u4f60\u64cd\u4f5c\u7cfb\u7edf\u7684Python\u7248\u672c\u3002\u5bf9\u4e8e\u5927\u591a\u6570\u7528\u6237\uff0c\u4e0b\u8f7d\u7a33\u5b9a\u7684\u7248\u672c\u5373\u53ef\uff0c\u6bd4\u5982Python<\/a> 3.x\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5Python<\/strong>\uff1a\u8fd0\u884c\u4e0b\u8f7d\u7684\u5b89\u88c5\u7a0b\u5e8f\u3002\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\uff0c\u786e\u4fdd\u52fe\u9009\u201cAdd Python to PATH\u201d\u9009\u9879\uff0c\u8fd9\u5c06\u4f7fPython\u547d\u4ee4\u5728\u547d\u4ee4\u884c\u4e2d\u53ef\u7528\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong>\uff1a\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6253\u5f00\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\uff0c\u8f93\u5165<code>python --version<\/code>\u6216<code>python3 --version<\/code>\uff08\u53d6\u51b3\u4e8e\u7cfb\u7edf\u914d\u7f6e\uff09\uff0c\u67e5\u770b\u662f\u5426\u6b63\u786e\u5b89\u88c5\u5e76\u663e\u793aPython\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u5b89\u88c5Visual Studio Code<\/p>\n<\/p>\n<p><p>Visual Studio Code\uff08VSCode\uff09\u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u4e14\u529f\u80fd\u5f3a\u5927\u7684\u4ee3\u7801\u7f16\u8f91\u5668\uff0c\u9002\u5408\u591a\u79cd\u7f16\u7a0b\u8bed\u8a00\uff0c\u5305\u62ecPython\u3002\u4ee5\u4e0b\u662f\u5b89\u88c5VSCode\u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4e0b\u8f7dVSCode<\/strong>\uff1a\u8bbf\u95eeVSCode\u7684\u5b98\u65b9\u7f51\u7ad9\uff08<a href=\"https:\/\/code.visualstudio.com\/%EF%BC%89%EF%BC%8C%E6%A0%B9%E6%8D%AE%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E9%80%89%E6%8B%A9%E9%80%82%E5%90%88%E7%9A%84%E7%89%88%E6%9C%AC%E8%BF%9B%E8%A1%8C%E4%B8%8B%E8%BD%BD%E3%80%82\">https:\/\/code.visualstudio.com\/\uff09\uff0c\u6839\u636e\u64cd\u4f5c\u7cfb\u7edf\u9009\u62e9\u9002\u5408\u7684\u7248\u672c\u8fdb\u884c\u4e0b\u8f7d\u3002<\/a><\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5VSCode<\/strong>\uff1a\u8fd0\u884c\u4e0b\u8f7d\u7684\u5b89\u88c5\u7a0b\u5e8f\uff0c\u6309\u7167\u63d0\u793a\u8fdb\u884c\u5b89\u88c5\u3002\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u53ef\u4ee5\u9009\u62e9\u6dfb\u52a0\u5230\u7cfb\u7edf\u8def\u5f84\uff0c\u4ee5\u4fbf\u5728\u547d\u4ee4\u884c\u4e2d\u5feb\u901f\u542f\u52a8VSCode\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u542f\u52a8VSCode<\/strong>\uff1a\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6253\u5f00VSCode\uff0c\u719f\u6089\u5176\u754c\u9762\u548c\u57fa\u672c\u529f\u80fd\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u5b89\u88c5Python\u6269\u5c55<\/p>\n<\/p>\n<p><p>\u4e3a\u4e86\u5728VSCode\u4e2d\u6709\u6548\u5730\u7f16\u5199\u548c\u8c03\u8bd5Python\u4ee3\u7801\uff0c\u9700\u8981\u5b89\u88c5Python\u6269\u5c55\u3002\u8fd9\u4e2a\u6269\u5c55\u63d0\u4f9b\u4e86\u8bed\u6cd5\u9ad8\u4eae\u3001\u81ea\u52a8\u8865\u5168\u3001\u8c03\u8bd5\u652f\u6301\u7b49\u529f\u80fd\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6253\u5f00\u6269\u5c55\u5e02\u573a<\/strong>\uff1a\u5728VSCode\u4e2d\uff0c\u70b9\u51fb\u5de6\u4fa7\u6d3b\u52a8\u680f\u4e2d\u7684\u6269\u5c55\u56fe\u6807\uff0c\u6253\u5f00\u6269\u5c55\u5e02\u573a\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u641c\u7d22Python\u6269\u5c55<\/strong>\uff1a\u5728\u641c\u7d22\u6846\u4e2d\u8f93\u5165\u201cPython\u201d\uff0c\u627e\u5230\u7531Microsoft\u53d1\u5e03\u7684Python\u6269\u5c55\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5Python\u6269\u5c55<\/strong>\uff1a\u70b9\u51fb\u201c\u5b89\u88c5\u201d\u6309\u94ae\uff0c\u7b49\u5f85\u5b89\u88c5\u5b8c\u6210\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0cVSCode\u53ef\u80fd\u4f1a\u63d0\u793a\u4f60\u5b89\u88c5\u5176\u4ed6\u63a8\u8350\u7684\u6269\u5c55\uff0c\u89c6\u9700\u8981\u9009\u62e9\u5b89\u88c5\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u914d\u7f6ePython\u89e3\u91ca\u5668<\/p>\n<\/p>\n<p><p>\u4e3a\u4e86\u8ba9VSCode\u6b63\u786e\u8fd0\u884cPython\u4ee3\u7801\uff0c\u9700\u8981\u914d\u7f6ePython\u89e3\u91ca\u5668\u3002Python\u89e3\u91ca\u5668\u662f\u8fd0\u884cPython\u4ee3\u7801\u7684\u6838\u5fc3\u7ec4\u4ef6\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6253\u5f00\u547d\u4ee4\u9762\u677f<\/strong>\uff1a\u5728VSCode\u4e2d\u6309\u4e0b<code>Ctrl+Shift+P<\/code>\uff08Windows\uff09\u6216<code>Cmd+Shift+P<\/code>\uff08Mac\uff09\u6253\u5f00\u547d\u4ee4\u9762\u677f\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9009\u62e9Python\u89e3\u91ca\u5668<\/strong>\uff1a\u5728\u547d\u4ee4\u9762\u677f\u4e2d\u8f93\u5165\u201cPython: Select Interpreter\u201d\uff0c\u6309\u4e0b\u56de\u8f66\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9009\u62e9\u5408\u9002\u7684\u89e3\u91ca\u5668<\/strong>\uff1aVSCode\u4f1a\u5217\u51fa\u7cfb\u7edf\u4e2d\u5b89\u88c5\u7684\u6240\u6709Python\u89e3\u91ca\u5668\u3002\u9009\u62e9\u4f60\u5b89\u88c5\u7684Python\u7248\u672c\uff0c\u901a\u5e38\u662f\u6700\u65b0\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u521b\u5efaPython\u6587\u4ef6<\/p>\n<\/p>\n<p><p>\u6709\u4e86Python\u89e3\u91ca\u5668\u548cVSCode\u7684\u652f\u6301\u540e\uff0c\u53ef\u4ee5\u5f00\u59cb\u521b\u5efa\u548c\u7f16\u5199Python\u4ee3\u7801\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efa\u65b0\u6587\u4ef6<\/strong>\uff1a\u5728VSCode\u4e2d\uff0c\u70b9\u51fb\u5de6\u4e0a\u89d2\u7684\u201c\u6587\u4ef6\u201d\u83dc\u5355\uff0c\u9009\u62e9\u201c\u65b0\u5efa\u6587\u4ef6\u201d\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4fdd\u5b58\u6587\u4ef6\u4e3aPython\u683c\u5f0f<\/strong>\uff1a\u5c06\u65b0\u5efa\u6587\u4ef6\u4fdd\u5b58\u4e3a<code>.py<\/code>\u683c\u5f0f\uff0c\u6bd4\u5982<code>hello.py<\/code>\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7f16\u5199Python\u4ee3\u7801<\/strong>\uff1a\u5728\u6587\u4ef6\u4e2d\u8f93\u5165Python\u4ee3\u7801\uff0c\u4f8b\u5982\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<\/ol>\n<p><p>\u516d\u3001\u8fd0\u884c\u548c\u8c03\u8bd5Python\u4ee3\u7801<\/p>\n<\/p>\n<p><p>VSCode\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u8fd0\u884c\u548c\u8c03\u8bd5\u529f\u80fd\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5728\u7f16\u5199\u4ee3\u7801\u7684\u8fc7\u7a0b\u4e2d\u5feb\u901f\u53d1\u73b0\u548c\u89e3\u51b3\u95ee\u9898\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u8fd0\u884cPython\u4ee3\u7801<\/strong>\uff1a\u5728\u7f16\u8f91\u5668\u4e2d\u6253\u5f00Python\u6587\u4ef6\uff0c\u70b9\u51fb\u53f3\u4e0a\u89d2\u7684\u201c\u8fd0\u884c\u201d\u6309\u94ae\uff0c\u6216\u8005\u6309\u4e0b<code>Ctrl+F5<\/code>\uff08Windows\uff09\u6216<code>Cmd+F5<\/code>\uff08Mac\uff09\u8fd0\u884c\u4ee3\u7801\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8c03\u8bd5Python\u4ee3\u7801<\/strong>\uff1aVSCode\u652f\u6301\u8c03\u8bd5Python\u4ee3\u7801\uff0c\u5305\u62ec\u8bbe\u7f6e\u65ad\u70b9\u3001\u9010\u6b65\u6267\u884c\u7b49\u3002\u5728\u4ee3\u7801\u884c\u53f7\u5de6\u4fa7\u70b9\u51fb\u8bbe\u7f6e\u65ad\u70b9\uff0c\u7136\u540e\u70b9\u51fb\u201c\u8c03\u8bd5\u201d\u6309\u94ae\u6216\u6309\u4e0b<code>F5<\/code>\u5f00\u59cb\u8c03\u8bd5\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u67e5\u770b\u8f93\u51fa<\/strong>\uff1a\u4ee3\u7801\u8fd0\u884c\u540e\uff0c\u8f93\u51fa\u7ed3\u679c\u4f1a\u663e\u793a\u5728VSCode\u7684\u7ec8\u7aef\u7a97\u53e3\u4e2d\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u5df2\u7ecf\u5728VSCode\u4e2d\u6210\u529f\u5bfc\u5165\u5e76\u8fd0\u884c\u4e86Python\u4ee3\u7801\u3002VSCode\u7684\u5f3a\u5927\u529f\u80fd\u548cPython\u7684\u7075\u6d3b\u6027\u76f8\u7ed3\u5408\uff0c\u53ef\u4ee5\u5927\u5927\u63d0\u9ad8\u5f00\u53d1\u6548\u7387\u548c\u4ee3\u7801\u8d28\u91cf\u3002\u968f\u7740\u719f\u7ec3\u5ea6\u7684\u63d0\u9ad8\uff0c\u4f60\u8fd8\u53ef\u4ee5\u63a2\u7d22VSCode\u7684\u66f4\u591a\u9ad8\u7ea7\u529f\u80fd\uff0c\u5982\u96c6\u6210\u7248\u672c\u63a7\u5236\u3001\u4ee3\u7801\u91cd\u6784\u3001\u81ea\u52a8\u5316\u6d4b\u8bd5\u7b49\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Visual Studio Code\u4e2d\u5b89\u88c5Python\u6269\u5c55\uff1f<\/strong><br \/>\u8981\u5728Visual Studio Code\u4e2d\u4f7f\u7528Python\uff0c\u60a8\u9700\u8981\u5b89\u88c5Python\u6269\u5c55\u3002\u53ef\u4ee5\u901a\u8fc7\u70b9\u51fb\u4fa7\u8fb9\u680f\u7684\u6269\u5c55\u56fe\u6807\uff08\u770b\u8d77\u6765\u50cf\u4e00\u4e2a\u65b9\u5757\uff09\uff0c\u5728\u641c\u7d22\u6846\u4e2d\u8f93\u5165\u201cPython\u201d\uff0c\u627e\u5230\u7531Microsoft\u63d0\u4f9b\u7684Python\u6269\u5c55\u5e76\u70b9\u51fb\u201c\u5b89\u88c5\u201d\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u91cd\u65b0\u542f\u52a8VS Code\u4ee5\u786e\u4fdd\u6269\u5c55\u6b63\u5e38\u5de5\u4f5c\u3002<\/p>\n<p><strong>\u5982\u4f55\u8bbe\u7f6ePython\u73af\u5883\u4ee5\u4fbf\u5728VS Code\u4e2d\u8fd0\u884c\u4ee3\u7801\uff1f<\/strong><br \/>\u5728VS Code\u4e2d\u8bbe\u7f6ePython\u73af\u5883\u53ef\u4ee5\u901a\u8fc7\u9009\u62e9\u5408\u9002\u7684Python\u89e3\u91ca\u5668\u6765\u5b9e\u73b0\u3002\u5728\u6253\u5f00\u7684Python\u6587\u4ef6\u4e2d\uff0c\u70b9\u51fb\u7a97\u53e3\u5de6\u4e0b\u89d2\u7684Python\u7248\u672c\u4fe1\u606f\uff0c\u9009\u62e9\u60a8\u9700\u8981\u7684Python\u89e3\u91ca\u5668\u3002\u786e\u4fdd\u5df2\u7ecf\u5728\u60a8\u7684\u8ba1\u7b97\u673a\u4e0a\u5b89\u88c5\u4e86\u76f8\u5e94\u7248\u672c\u7684Python\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728VS Code\u4e2d\u521b\u5efa\u548c\u8fd0\u884cPython\u6587\u4ef6\uff1f<\/strong><br \/>\u521b\u5efaPython\u6587\u4ef6\u975e\u5e38\u7b80\u5355\u3002\u5728VS Code\u4e2d\uff0c\u60a8\u53ef\u4ee5\u70b9\u51fb\u201c\u6587\u4ef6\u201d\u83dc\u5355\uff0c\u7136\u540e\u9009\u62e9\u201c\u65b0\u5efa\u6587\u4ef6\u201d\uff0c\u63a5\u7740\u5c06\u6587\u4ef6\u4fdd\u5b58\u4e3a\u4ee5\u201c.py\u201d\u7ed3\u5c3e\u7684\u540d\u79f0\u3002\u8981\u8fd0\u884cPython\u4ee3\u7801\uff0c\u53ef\u4ee5\u4f7f\u7528\u5feb\u6377\u952e\uff08\u901a\u5e38\u662fCtrl + Alt + N\uff09\u6216\u5728\u7ec8\u7aef\u4e2d\u8f93\u5165\u201cpython \u6587\u4ef6\u540d.py\u201d\u547d\u4ee4\u6765\u6267\u884c\u3002\u786e\u4fdd\u60a8\u7684\u7ec8\u7aef\u5df2\u7ecf\u5207\u6362\u5230Python\u73af\u5883\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728VSCode\u4e2d\u5bfc\u5165Python\u7684\u6b65\u9aa4\u5305\u62ec\uff1a\u5b89\u88c5Python\u3001\u5b89\u88c5VSCode\u3001\u5b89\u88c5Python\u6269\u5c55\u3001\u914d\u7f6ePy [&hellip;]","protected":false},"author":3,"featured_media":947280,"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\/947275"}],"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=947275"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/947275\/revisions"}],"predecessor-version":[{"id":947282,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/947275\/revisions\/947282"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/947280"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=947275"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=947275"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=947275"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}