{"id":175376,"date":"2024-05-08T18:50:39","date_gmt":"2024-05-08T10:50:39","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/175376.html"},"modified":"2024-05-08T18:50:55","modified_gmt":"2024-05-08T10:50:55","slug":"mac%e7%8e%af%e5%a2%83%e4%b8%8b%ef%bc%8cvscode%e5%a6%82%e4%bd%95%e9%85%8d%e7%bd%aepython%e5%bc%80%e5%8f%91%e7%8e%af%e5%a2%83","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/175376.html","title":{"rendered":"mac\u73af\u5883\u4e0b\uff0cVSCode\u5982\u4f55\u914d\u7f6ePython\u5f00\u53d1\u73af\u5883"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/27053220\/04753536-8183-4394-9182-522706af24d0.webp\" alt=\"mac\u73af\u5883\u4e0b\uff0cVSCode\u5982\u4f55\u914d\u7f6ePython\u5f00\u53d1\u73af\u5883\" \/><\/p>\n<p><p><strong>\u5728Mac\u73af\u5883\u4e0b\u914d\u7f6eVSCode\u4f5c\u4e3aPython\u5f00\u53d1\u73af\u5883\u9700\u8981\u8fdb\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u5b89\u88c5VSCode\u3001\u5b89\u88c5Python\u3001\u914d\u7f6ePython\u89e3\u91ca\u5668\u3001\u5b89\u88c5\u5e76\u914d\u7f6e\u6269\u5c55\u3001\u8bbe\u7f6e\u4ee3\u7801\u683c\u5f0f\u5316\u4e0e\u68c0\u67e5<\/strong>\u3002\u9996\u5148\uff0c\u786e\u4fddMac\u4e0a\u5df2\u7ecf\u5b89\u88c5\u4e86Python\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0cMac\u7cfb\u7edf\u81ea\u5e26Python\uff0c\u4f46\u5b83\u53ef\u80fd\u662f\u8f83\u65e7\u7684\u7248\u672c\u3002\u66f4\u65b0Python\u81f3\u6700\u65b0\u7248\u53ef\u4ee5\u83b7\u5f97\u66f4\u597d\u7684\u6027\u80fd\u548c\u6700\u65b0\u7684\u529f\u80fd\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u914d\u7f6ePython\u89e3\u91ca\u5668\u662f\u5173\u952e\u4e00\u6b65\uff0c\u5b83\u8ba9VSCode\u77e5\u9053\u5e94\u5f53\u8fd0\u884c\u54ea\u4e2a\u7248\u672c\u7684Python\uff0c\u5c24\u5176\u662f\u5728\u4f60\u7684\u7cfb\u7edf\u4e2d\u5b89\u88c5\u6709\u591a\u4e2aPython\u7248\u672c\u7684\u60c5\u51b5\u4e0b\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u5b89\u88c5VSCode\u548cPython<\/h3>\n<\/p>\n<p><p><strong>\u5b89\u88c5VSCode\uff1a<\/strong><\/p>\n<\/p>\n<ol>\n<li>\u8bbf\u95ee\u5b98\u65b9Visual Studio Code\u7f51\u7ad9\uff1a<a href=\"https:\/\/code.visualstudio.com\/\">https:\/\/code.visualstudio.com\/<\/a>\u3002<\/li>\n<li>\u4e0b\u8f7d\u9002\u7528\u4e8eMac\u7684\u7a33\u5b9a\u7248\u672c\uff0c\u5e76\u6309\u7167\u6307\u793a\u5b8c\u6210\u5b89\u88c5\u3002<\/li>\n<\/ol>\n<p><p><strong>\u5b89\u88c5Python\uff1a<\/strong><\/p>\n<\/p>\n<ol>\n<li>\u8bbf\u95ee\u5b98\u65b9Python\u4e0b\u8f7d\u9875\u9762\uff1a<a href=\"https:\/\/www.python.org\/downloads\/\">https:\/\/www.python.org\/downloads\/<\/a>\u3002<\/li>\n<li>\u9009\u62e9\u9002\u4e8eMac\u7684\u5b89\u88c5\u5305\uff0c\u5e76\u6839\u636e\u9875\u9762\u6307\u793a\u5b8c\u6210\u5b89\u88c5\u8fc7\u7a0b\u3002<\/li>\n<\/ol>\n<p><h3>\u4e8c\u3001\u914d\u7f6ePython\u89e3\u91ca\u5668<\/h3>\n<\/p>\n<p><p><strong>\u9009\u62e9\u89e3\u91ca\u5668\uff1a<\/strong><\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00VSCode\u3002<\/li>\n<li>\u4f7f\u7528\u5feb\u6377\u952e<code>Cmd+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\u6b63\u786e\u7684Python\u89e3\u91ca\u5668\u7248\u672c\u3002<\/li>\n<\/ol>\n<p><h3>\u4e09\u3001\u5b89\u88c5\u6269\u5c55<\/h3>\n<\/p>\n<p><p><strong>\u5b89\u88c5Python\u6269\u5c55\uff1a<\/strong><\/p>\n<\/p>\n<ol>\n<li>\u5728VSCode\u4e2d\u6253\u5f00\u6269\u5c55\u9762\u677f\uff0c\u641c\u7d22\u201cPython\u201d\u3002<\/li>\n<li>\u9009\u62e9\u7531Microsoft\u53d1\u5e03\u7684\u5b98\u65b9Python\u6269\u5c55\uff0c\u5e76\u70b9\u51fb\u5b89\u88c5\u3002<\/li>\n<\/ol>\n<p><p><strong>\u914d\u7f6elinting\uff1a<\/strong><\/p>\n<\/p>\n<ol>\n<li>\u5728VSCode\u8bbe\u7f6e\u4e2d\u542f\u7528linting\u529f\u80fd\uff0c\u4ee5\u63d0\u5347\u4ee3\u7801\u8d28\u91cf\u3002<\/li>\n<li>\u53ef\u9009\u5b89\u88c5Flake8\u6216PyLint\u8fd9\u7c7blinter\u5de5\u5177\u3002<\/li>\n<\/ol>\n<p><p><strong>\u5b89\u88c5\u5176\u4ed6\u6709\u7528\u6269\u5c55\uff1a<\/strong><\/p>\n<\/p>\n<ul>\n<li>GitLens\uff1a\u7528\u4e8e\u589e\u5f3a\u5185\u7f6eGit\u529f\u80fd\u3002<\/li>\n<li>Bracket P<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>r Colorizer\uff1a\u5f69\u8272\u6807\u51fa\u914d\u5bf9\u7684\u62ec\u53f7\uff0c\u589e\u5f3a\u4ee3\u7801\u53ef\u8bfb\u6027\u3002<\/li>\n<li>Django\uff1a\u82e5\u8fdb\u884cDjango\u5f00\u53d1\uff0c\u8fd9\u4e2a\u6269\u5c55\u5f88\u6709\u5e2e\u52a9\u3002<\/li>\n<\/ul>\n<p><h3>\u56db\u3001\u914d\u7f6ePython\u73af\u5883<\/h3>\n<\/p>\n<p><p><strong>\u521b\u5efa\u865a\u62df\u73af\u5883\uff1a<\/strong><\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u7ec8\u7aef\u3002<\/li>\n<li>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u5de5\u4f5c\u76ee\u5f55\u5e76\u8fdb\u5165\u8be5\u76ee\u5f55\u3002<\/li>\n<li>\u8fd0\u884c<code>python3 -m venv venv<\/code>\u521b\u5efa\u865a\u62df\u73af\u5883\u3002<\/li>\n<\/ol>\n<p><p><strong>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a<\/strong><\/p>\n<\/p>\n<ol>\n<li>\u5728VSCode\u7684\u7ec8\u7aef\u4e2d\u8fd0\u884c<code>source venv\/bin\/activate<\/code>\u6fc0\u6d3b\u8be5\u73af\u5883\u3002<\/li>\n<\/ol>\n<p><h3>\u4e94\u3001\u4ee3\u7801\u683c\u5f0f\u5316\u548c\u9519\u8bef\u68c0\u67e5<\/h3>\n<\/p>\n<p><p><strong>\u5b89\u88c5\u4ee3\u7801\u683c\u5f0f\u5316\u5de5\u5177\uff1a<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u5b89\u88c5autopep8\u6216black\u4f5c\u4e3a\u4ee3\u7801\u683c\u5f0f\u5316\u5de5\u5177\u3002<\/li>\n<li>\u5728VSCode\u4e2d\u8bbe\u7f6e\u683c\u5f0f\u5316\u5feb\u6377\u952e\uff0c\u4f8b\u5982\u5728\u4fdd\u5b58\u6587\u4ef6\u65f6\u81ea\u52a8\u683c\u5f0f\u5316\u3002<\/li>\n<\/ul>\n<p><p><strong>\u914d\u7f6e\u4ee3\u7801\u68c0\u67e5\uff1a<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u914d\u7f6elinter\uff0c\u4f8b\u5982PyLint\u6216Flake8\uff0c\u4ee5\u8fdb\u884c\u4ee3\u7801\u8d28\u91cf\u68c0\u67e5\u3002<\/li>\n<li>\u5728VSCode\u7684\u8bbe\u7f6e\u4e2d\u8fdb\u884c\u914d\u7f6e\uff0c\u786e\u4fdd\u5728\u7f16\u7801\u8fc7\u7a0b\u4e2d\u5b9e\u65f6\u63d0\u4f9b\u53cd\u9988\u3002<\/li>\n<\/ul>\n<p><h3>\u516d\u3001\u8fd0\u884c\u548c\u8c03\u8bd5<\/h3>\n<\/p>\n<p><p><strong>\u914d\u7f6e\u8fd0\u884c\u73af\u5883\uff1a<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u901a\u8fc7\u914d\u7f6e<code>.vscode\/launch.json<\/code>\u6587\u4ef6\u6765\u81ea\u5b9a\u4e49\u8fd0\u884c\u548c\u8c03\u8bd5\u8bbe\u7f6e\u3002<\/li>\n<\/ul>\n<p><p><strong>\u4f7f\u7528\u8c03\u8bd5\u5668\uff1a<\/strong><\/p>\n<\/p>\n<ul>\n<li>\u7406\u89e3\u8c03\u8bd5\u9762\u677f\u7684\u4f7f\u7528\uff0c\u5305\u62ec\u8bbe\u7f6e\u65ad\u70b9\u3001\u6b65\u8fdb\u3001\u67e5\u770b\u53d8\u91cf\u7b49\u3002<\/li>\n<\/ul>\n<p><p>\u914d\u7f6e\u597d\u4ee5\u4e0a\u73af\u8282\u540e\uff0cMac\u4e0a\u7684VSCode\u5c06\u6210\u4e3a\u4e00\u4e2a\u5f3a\u5927\u7684Python\u5f00\u53d1\u73af\u5883\u3002\u8fd9\u5c06\u5e2e\u52a9\u63d0\u5347\u5f00\u53d1\u6548\u7387\u3001\u6539\u5584\u4ee3\u7801\u8d28\u91cf\u5e76\u7b80\u5316\u8c03\u8bd5\u8fc7\u7a0b\u3002\u8bb0\u5f97\u4e0d\u65ad\u63a2\u7d22\u5176\u4ed6\u6269\u5c55\u548c\u5de5\u5177\uff0c\u8fd9\u4e9b\u90fd\u5c06\u8fdb\u4e00\u6b65\u4e30\u5bcc\u4f60\u7684\u5f00\u53d1\u4f53\u9a8c\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>\u5982\u4f55\u5728Mac\u73af\u5883\u4e0b\u5b89\u88c5VSCode\uff1f<\/strong><\/p>\n<p>\u9996\u5148\uff0c\u60a8\u53ef\u4ee5\u5728VSCode\u5b98\u65b9\u7f51\u7ad9\u4e0a\u4e0b\u8f7dMac\u7248\u672c\u7684\u5b89\u88c5\u7a0b\u5e8f\uff0c\u7136\u540e\u6309\u7167\u63d0\u793a\u8fdb\u884c\u5b89\u88c5\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u5728\u5e94\u7528\u7a0b\u5e8f\u6587\u4ef6\u5939\u91cc\u627e\u5230VSCode\u56fe\u6807\uff0c\u5e76\u5c06\u5176\u62d6\u653e\u5230Dock\u680f\u4e2d\u65b9\u4fbf\u5feb\u901f\u8bbf\u95ee\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Mac\u73af\u5883\u4e0b\u914d\u7f6ePython\u5f00\u53d1\u73af\u5883\uff1f<\/strong><\/p>\n<ol>\n<li>\u9996\u5148\uff0c\u60a8\u9700\u8981\u5728Mac\u4e0a\u5b89\u88c5Python\u3002\u524d\u5f80Python\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684Python\u5b89\u88c5\u7a0b\u5e8f\uff0c\u5e76\u6309\u7167\u63d0\u793a\u8fdb\u884c\u5b89\u88c5\u3002<\/li>\n<li>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6253\u5f00VSCode\u5e76\u70b9\u51fb\u5de6\u4fa7\u7684\u6269\u5c55\u56fe\u6807\uff08\u7c7b\u4f3c\u4e8e\u65b9\u5757\u7684\u56fe\u6807\uff09\uff0c\u641c\u7d22\u5e76\u5b89\u88c5Python\u6269\u5c55\u3002<\/li>\n<li>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u70b9\u51fb\u5de6\u4fa7\u7684\u8c03\u8bd5\u56fe\u6807\uff08\u7c7b\u4f3c\u4e8e\u866b\u5b50\u7684\u56fe\u6807\uff09\uff0c\u7136\u540e\u70b9\u51fb\u83dc\u5355\u4e2d\u7684&quot;\u521b\u5efa\u65b0\u7684\u542f\u52a8\u914d\u7f6e&quot;\u3002<\/li>\n<li>\u9009\u62e9&quot;Python&quot;\u4f5c\u4e3a\u542f\u52a8\u914d\u7f6e\uff0c\u5e76\u6839\u636e\u63d0\u793a\u9009\u62e9\u60a8\u8981\u4f7f\u7528\u7684Python\u89e3\u91ca\u5668\u3002<\/li>\n<li>\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528VSCode\u8fdb\u884cPython\u4ee3\u7801\u7f16\u5199\u3001\u8c03\u8bd5\u7b49\u64cd\u4f5c\u3002<\/li>\n<\/ol>\n<p><strong>\u5982\u4f55\u8fd0\u884cPython\u4ee3\u7801\u5e76\u67e5\u770b\u8f93\u51fa\u7ed3\u679c\uff1f<\/strong><\/p>\n<ol>\n<li>\u9996\u5148\uff0c\u5728VSCode\u4e2d\u6253\u5f00\u60a8\u60f3\u8981\u8fd0\u884c\u7684Python\u6587\u4ef6\u3002<\/li>\n<li>\u7136\u540e\uff0c\u4f7f\u7528\u5feb\u6377\u952e&quot;Shift+Enter&quot;\u6216\u8005\u53f3\u952e\u70b9\u51fb\u6587\u4ef6\u5e76\u9009\u62e9&quot;\u8fd0\u884cPython\u6587\u4ef6&quot;\u6765\u8fd0\u884c\u4ee3\u7801\u3002<\/li>\n<li>\u8fd0\u884c\u5b8c\u6210\u540e\uff0c\u60a8\u53ef\u4ee5\u5728VSCode\u7684\u7ec8\u7aef\u7a97\u53e3\u4e2d\u770b\u5230\u4ee3\u7801\u7684\u8f93\u51fa\u7ed3\u679c\u3002\u60a8\u8fd8\u53ef\u4ee5\u901a\u8fc7\u5728\u4ee3\u7801\u4e2d\u4f7f\u7528&quot;print&quot;\u51fd\u6570\u6765\u8f93\u51fa\u66f4\u591a\u7684\u8c03\u8bd5\u4fe1\u606f\u3002<\/li>\n<\/ol>\n<p>\u8bf7\u6ce8\u610f\uff0c\u4ee5\u4e0a\u6b65\u9aa4\u4ec5\u4e3a\u57fa\u672c\u914d\u7f6e\uff0c\u6839\u636e\u60a8\u7684\u5177\u4f53\u9700\u6c42\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u5b89\u88c5\u5176\u4ed6\u6269\u5c55\u6216\u914d\u7f6e\u8fdb\u4e00\u6b65\u4f18\u5316\u60a8\u7684Python\u5f00\u53d1\u73af\u5883\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Mac\u73af\u5883\u4e0b\u914d\u7f6eVSCode\u4f5c\u4e3aPython\u5f00\u53d1\u73af\u5883\u9700\u8981\u8fdb\u884c\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u5b89\u88c5VSCode\u3001\u5b89\u88c5Python\u3001\u914d [&hellip;]","protected":false},"author":3,"featured_media":175416,"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\/175376"}],"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=175376"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/175376\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/175416"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=175376"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=175376"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=175376"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}