﻿{"id":19573,"date":"2023-01-06T08:25:27","date_gmt":"2023-01-06T00:25:27","guid":{"rendered":"https:\/\/www.linuxmi.com\/?p=19573"},"modified":"2023-01-05T20:30:43","modified_gmt":"2023-01-05T12:30:43","slug":"visual-studio-code-2022-12","status":"publish","type":"post","link":"https:\/\/www.linuxmi.com\/visual-studio-code-2022-12.html","title":{"rendered":"VS Code 2022 \u5e74 12 \u6708\u7248\u672c\u4e2d\u7684 Python \u6709\u54ea\u4e9b\u65b0\u589e\u529f\u80fd\uff1f"},"content":{"rendered":"<p>\u5fae\u8f6f\u5728\u5176\u5f00\u53d1\u8005\u535a\u5ba2\u7f51\u7ad9\u4e0a\u5ba3\u5e03\uff0c2022 \u5e74 12 \u6708\u53d1\u5e03\u7684 Visual Studio Code Python \u6269\u5c55\u73b0\u5df2\u63a8\u51fa\uff01\u8fd9\u4e9b\u6269\u5c55\u5904\u4e8e\u9884\u53d1\u5e03\u9636\u6bb5\uff0c\u4f46\u53ef\u4f9b\u516c\u4f17\u8bd5\u7528\u3002\u4ee5\u4e0b\u662f\u8fd9\u4e2a 2022 \u5e74 12 \u6708\u7248\u672c\u7684\u529f\u80fd\u3002<\/p>\n<h2 id=\"auto-indentation-with-pylance\">1. \u4f7f\u7528 Pylance \u81ea\u52a8\u7f29\u8fdb<\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-19575\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2023\/01\/2-1.png\" alt=\"\" width=\"1280\" height=\"847\" \/><\/p>\n<p>Pylance \u6269\u5c55\u4e2d\u589e\u52a0\u4e86\u81ea\u52a8\u7f29\u8fdb\u529f\u80fd\u3002\u6b64\u529f\u80fd\u4f1a\u81ea\u52a8\u5728\u60a8\u7684\u4ee3\u7801\u4e2d\u521b\u5efa\u6b63\u786e\u7684\u7f29\u8fdb\u3002\u8fd9\u5141\u8bb8\u7a0b\u5e8f\u5458\u5c06\u66f4\u591a\u7684\u65f6\u95f4\u5206\u914d\u7ed9\u4ee3\u7801\u7684\u903b\u8f91\u90e8\u5206\uff0c\u800c\u5c06\u66f4\u5c11\u7684\u65f6\u95f4\u5206\u914d\u7ed9\u683c\u5f0f\u5316\u3002\u60a8\u4e5f\u53ef\u4ee5\u5728<a href=\"https:\/\/code.visualstudio.com\/insiders\/\" target=\"_blank\" rel=\"nofollow noopener\">VS Code &#8211; Insiders<\/a>\uff08\u9700\u8981\u6ce8\u518c\uff09\u4e2d\u5c1d\u8bd5\u4e00\u4e0b\u3002<\/p>\n<p>\u5b89\u88c5 VS Code Insiders \u540e\uff0c\u8f6c\u5230\u5e02\u573a\u5e76\u5b89\u88c5<strong>Pylance<\/strong>\u6269\u5c55\u3002\u5bfc\u822a\u5230 \u67e5\u770b<strong>View &gt; \u547d\u4ee4\u9762\u677fCommand Palette<\/strong>\uff0c\u952e\u5165<strong>Preferences<\/strong>\uff0c\u7136\u540e\u8fd0\u884c<strong>\u200b\u200bOpen User Settings (JSON)\u3002<\/strong>\u786e\u4fdd <strong>editor.formatOnType <\/strong>\u8bbe\u7f6e\u4e3a true\u3002\u5b83\u63a7\u5236\u7f16\u8f91\u5668\u662f\u5426\u4f1a\u5728\u952e\u5165\u540e\u81ea\u52a8\u683c\u5f0f\u5316\u4e00\u884c\u4ee3\u7801\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-19576\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2023\/01\/3-1.png\" alt=\"\" width=\"2586\" height=\"1712\" \/> <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-19577\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2023\/01\/4-1.png\" alt=\"\" width=\"1280\" height=\"847\" \/><\/p>\n<p>\u8bbe\u7f6e\u4e3a true \u540e\uff0c\u7ee7\u7eed\u7f16\u5199\u60a8\u7684\u4ee3\u7801\u4ee5\u4eab\u53d7\u6b64\u65b0\u529f\u80fd\u3002<\/p>\n<h2 id=\"python-for-the-web-extension\">2. \u7528\u4e8e Web \u6269\u5c55\u7684 Python<\/h2>\n<p>&nbsp;<\/p>\n<p>\u8fd9\u662f\u4e00\u4e2a\u65b0\u7684 VS Code \u6269\u5c55\uff0c\u5141\u8bb8\u60a8\u5728\u6d4f\u89c8\u5668\u4e2d\u8fd0\u884c\u548c\u8c03\u8bd5 Python \u4ee3\u7801\u3002\u5b83\u4f7f\u7528WebAssembly\u4f5c\u4e3a\u6267\u884c\u5f15\u64ce\u3002\u5b83\u5904\u4e8e\u5b9e\u9a8c\u9636\u6bb5\uff0c\u56e0\u6b64\u60a8\u4e0d\u5e94\u8be5\u5c06\u5b83\u7528\u4e8e Python \u751f\u4ea7\u5f00\u53d1\u3002\u8981\u5f00\u59cb\u4f7f\u7528\u5b83\uff0c\u8bf7\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a<\/p>\n<ol>\n<li>\u6253\u5f00\u57fa\u4e8e Chrome \u7684\u6d4f\u89c8\u5668\u3002<\/li>\n<li>\u4f7f\u7528\u4ee5\u4e0b\u5730\u5740\u5bfc\u822a\u5230\u60a8\u7684 GitHub \u5b58\u50a8\u5e93\u3002\u5206\u522b\u7528\u60a8\u7684 GitHub \u7528\u6237\u540d\u548c\u5b58\u50a8\u5e93\u66ff\u6362\u7528\u6237\u540d\u548c repo \u90e8\u5206\u3002\u8f93\u51fa\u5e94\u5982\u4e0b\u6240\u793a\u3002https:\/\/insiders.vscode.dev\/github\/{username}\/{repo}?vscode-coi=.\n<div class=\"body-img landscape\">\n<div class=\"responsive-img image-expandable img-article-item\" data-img-url=\"https:\/\/static1.makeuseofimages.com\/wordpress\/wp-content\/uploads\/2022\/12\/vscode-2022-python-for-the-web-launch-image.jpg\" data-modal-id=\"single-image-modal\" data-modal-container-id=\"single-image-modal-container\" data-img-caption=\"&quot;&quot;\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-19578\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2023\/01\/vscode-2022-python-for-the-web-launch-image.jpg\" alt=\"\" width=\"1030\" height=\"690\" \/><\/figure>\n<\/div>\n<\/div>\n<\/li>\n<li>\u8f6c\u5230\u5e02\u573a\u5e76\u5b89\u88c5 <strong>Experimental &#8211; Python for the Web <\/strong>\u6269\u5c55\u3002<\/li>\n<li>\u6253\u5f00\u4f60\u7684 Python \u6587\u4ef6\u3002<\/li>\n<li>\u6309 <strong>F5 <\/strong>\u5f00\u59cb\u8c03\u8bd5\u6216\u6309<strong>CTRL+F5<\/strong>\u8fd0\u884c\u4ee3\u7801\u800c\u4e0d\u8c03\u8bd5\u3002<\/li>\n<\/ol>\n<h3 id=\"limitations-of-the-python-for-the-web-extension\">\u7528\u4e8e Web \u6269\u5c55\u7684 Python \u7684\u5c40\u9650\u6027<\/h3>\n<p>\u5982\u524d\u6240\u8ff0\uff0c\u7528\u4e8e Web \u6269\u5c55\u7684 Python \u662f\u5b9e\u9a8c\u6027\u7684\uff0c\u56e0\u6b64\u6709\u4e00\u4e9b\u9650\u5236\u3002<\/p>\n<ol>\n<li>\u5927\u591a\u6570 Intellisense \u63d2\u4ef6\u548c\u6269\u5c55\u4e0d\u53ef\u7528\u4e8e Python for web\u3002\u4e0d\u53ef\u7528\u7684\u7528\u8b66\u544a\u7b26\u53f7\u8868\u793a\uff0c\u5982\u4e0b\u6240\u793a\u3002\n<div class=\"body-img landscape\">\n<div class=\"responsive-img image-expandable img-article-item\" data-img-url=\"https:\/\/static1.makeuseofimages.com\/wordpress\/wp-content\/uploads\/2022\/12\/vscode-2022-python-for-the-web-limitations.jpg\" data-modal-id=\"single-image-modal\" data-modal-container-id=\"single-image-modal-container\" data-img-caption=\"&quot;&quot;\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-19579\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2023\/01\/vscode-2022-python-for-the-web-limitations.jpg\" alt=\"\" width=\"1030\" height=\"692\" \/><\/figure>\n<\/div>\n<\/div>\n<\/li>\n<li>Web \u7248\u672c\u4f7f\u7528\u7684 Python \u89e3\u91ca\u5668\u6709\u4ee5\u4e0b\u9650\u5236\u3002\n<ul>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>\u5b83\u4e0d\u652f\u6301\u00a0<strong>pip<\/strong><\/li>\n<li>\u5b83\u4e0d\u652f\u6301<strong>\u5957\u63a5\u5b57<\/strong><\/li>\n<li>\u5b83\u4e0d\u652f\u6301<strong>\u539f\u751f Python \u6a21\u5757<\/strong><\/li>\n<li>\u6ca1\u6709<strong>\u7ebf\u7a0b<\/strong>\u652f\u6301\uff0c\u56e0\u6b64\u4e5f\u6ca1\u6709<strong>\u5f02\u6b65<\/strong>\u652f\u6301\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>\u56e0\u6b64\uff0c\u60a8\u5bf9\u8be5\u529f\u80fd\u7684\u4f7f\u7528\u5e94\u4ec5\u9650\u4e8e\u539f\u578b\u9879\u76ee\u548c\u6d4b\u8bd5\u73af\u5883\u3002<\/p>\n<h2>3\u3001Ruff \u6269\u5c55<\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-19580\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2023\/01\/5-1.png\" alt=\"\" width=\"2432\" height=\"1505\" \/><\/p>\n<p>\u6b64\u6269\u5c55\u63d0\u4f9b\u5bf9 Ruff linter \u7684\u652f\u6301\u3002\u6700\u60ca\u4eba\u7684\u529f\u80fd\u662f\u5b83\u63d0\u4f9b\u4e86<strong>\u5feb\u901f\u4fee\u590d<\/strong>\u64cd\u4f5c\uff0c\u53ef\u4ee5\u81ea\u52a8\u66f4\u6b63\u53ef\u81ea\u52a8\u4fee\u590d\u7684\u8fdd\u89c4\u884c\u4e3a\u3002<strong>Ruff <\/strong>\u6269\u5c55\u4e0d\u9700\u8981\u60a8\u4f7f\u7528\u00a0 VS Code insiders \u6765\u5c1d\u8bd5\u3002\u5b83\u4e5f\u53ef\u4ee5\u5b89\u88c5\u5728\u666e\u901a\u7684 VS Code \u4e2d\u3002\u8981\u5c1d\u8bd5\u4e00\u4e0b\uff0c\u8bf7\u5bfc\u822a\u5230 VS Code \u5e02\u573a\u5e76\u5b89\u88c5\u5b83\u3002<\/p>\n<p>\u5b83\u901a\u8fc7\u5728\u60a8\u7f16\u8f91\u6216\u6253\u5f00 Python \u6587\u4ef6\u65f6\u8fd0\u884c\u60a8\u7684\u4ee3\u7801\u6765\u4fee\u590d\u4ee3\u7801\u4e2d\u7684\u8fdd\u89c4\u884c\u4e3a\u3002\u8981\u4f7f\u7528\u5b83\uff0c\u8bf7\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a<\/p>\n<ol>\n<li><strong>\u6253\u5f00 <\/strong>Visual Studio Code<\/li>\n<li>\u521b\u5efa\u4e00\u4e2a\u65b0\u7684 Python \u6587\u4ef6\u5e76\u7f16\u5199\u4ee3\u7801<\/li>\n<li>\u5982\u679c\u60a8\u6709\u4ee5\u524d\u4fdd\u5b58\u7684 Python \u6e90\u6587\u4ef6\uff0c\u8bf7\u5728 Visual Studio Code \u4e2d\u6253\u5f00\u5b83<\/li>\n<li>\u901a\u8fc7\u5bfc\u822a\u5230 <strong>View &gt; Command Palette <\/strong>\u8fd0\u884c Ruff \u6269\u5c55\uff0c\u952e\u5165<strong>Ruff\uff0c<\/strong>\u7136\u540e\u8fd0\u884c<strong>\u200b\u200b Ruff: Fix all auto-fixable problems\uff0c\u5982\u4e0b\u6240\u793a<\/strong>\u3002\n<div class=\"body-img landscape\">\n<div class=\"responsive-img image-expandable img-article-item\" data-img-url=\"https:\/\/static1.makeuseofimages.com\/wordpress\/wp-content\/uploads\/2022\/12\/vscode-2022-ruff-extension-auto-fix.jpg\" data-modal-id=\"single-image-modal\" data-modal-container-id=\"single-image-modal-container\" data-img-caption=\"&quot;&quot;\">\n<figure><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-19581\" src=\"https:\/\/www.linuxmi.com\/wp-content\/uploads\/2023\/01\/6-1.png\" alt=\"\" width=\"2432\" height=\"1505\" \/><\/figure>\n<\/div>\n<\/div>\n<\/li>\n<li>\u8fd0\u884c\u540e\uff0cRuff \u5c06\u4fee\u590d Python \u4ee3\u7801\u4e2d\u7684\u95ee\u9898\u3002<\/li>\n<\/ol>\n<h2 id=\"why-you-should-try-the-new-python-extensions-in-visual-studio-code\">\u4e3a\u4ec0\u4e48\u4f60\u5e94\u8be5\u5728 Visual Studio Code \u4e2d\u5c1d\u8bd5\u65b0\u7684 Python \u6269\u5c55<\/h2>\n<p>\u5411 Visual Studio Code \u6269\u5c55\u6dfb\u52a0\u65b0\u529f\u80fd\u4f7f\u5f97\u5728\u5e73\u53f0\u4e0a\u4f7f\u7528 Python \u8fdb\u884c\u5f00\u53d1\u66f4\u52a0\u9ad8\u6548\u3002\u60a8\u5c06\u82b1\u66f4\u5c11\u7684\u65f6\u95f4\u62c5\u5fc3\u4ee3\u7801\u683c\u5f0f\uff0c\u4ece\u800c\u82b1\u66f4\u591a\u7684\u65f6\u95f4\u5904\u7406\u4ee3\u7801\u7684\u903b\u8f91\u3002<\/p>\n<p>\u6b64\u5916\uff0cVisual Studio Code \u7b49\u5f00\u6e90 IDE \u4f1a\u5b9a\u671f\u8fdb\u884c\u529f\u80fd\u66f4\u65b0\u3002\u8fd9\u662f\u7531\u4e8e\u53c2\u4e0e IDE \u5f00\u53d1\u7684\u4eba\u5458\u4f17\u591a\u3002\u8fd9\u4e9b\u66f4\u65b0\u5e26\u6709\u65b0\u529f\u80fd\uff0c\u53ef\u4ee5\u5728\u4f7f\u7528 IDE \u65f6\u5e26\u6765\u66f4\u597d\u7684\u7f16\u7801\u4f53\u9a8c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5fae\u8f6f\u5728\u5176\u5f00\u53d1\u8005\u535a\u5ba2\u7f51\u7ad9\u4e0a\u5ba3\u5e03\uff0c2022 \u5e74 12 \u6708\u53d1\u5e03\u7684 Visual Studio Code P &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[2],"tags":[101],"class_list":["post-19573","post","type-post","status-publish","format-standard","hentry","category-zixun","tag-vs-code"],"aioseo_notices":[],"views":326,"_links":{"self":[{"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/posts\/19573","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/comments?post=19573"}],"version-history":[{"count":4,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/posts\/19573\/revisions"}],"predecessor-version":[{"id":19584,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/posts\/19573\/revisions\/19584"}],"wp:attachment":[{"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/media?parent=19573"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/categories?post=19573"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxmi.com\/wp-json\/wp\/v2\/tags?post=19573"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}