{"id":1151972,"date":"2025-01-13T17:19:57","date_gmt":"2025-01-13T09:19:57","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1151972.html"},"modified":"2025-01-13T17:19:59","modified_gmt":"2025-01-13T09:19:59","slug":"vscode%e5%a6%82%e4%bd%95%e8%b0%83%e8%af%95python%e4%bb%a3%e7%a0%81","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1151972.html","title":{"rendered":"vscode\u5982\u4f55\u8c03\u8bd5python\u4ee3\u7801"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25182041\/f5b86d0f-a68a-42ad-81db-231b8fd0d7bb.webp\" alt=\"vscode\u5982\u4f55\u8c03\u8bd5python\u4ee3\u7801\" \/><\/p>\n<p><p> Visual Studio Code\uff08VS Code\uff09\u662f\u4e00\u6b3e\u5f3a\u5927\u4e14\u7075\u6d3b\u7684\u4ee3\u7801\u7f16\u8f91\u5668\uff0c\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u8c03\u8bd5Python\u4ee3\u7801\u3002<strong>\u5b89\u88c5Python\u6269\u5c55\u3001\u914d\u7f6elaunch.json\u6587\u4ef6\u3001\u8bbe\u7f6e\u65ad\u70b9\u3001\u4f7f\u7528\u8c03\u8bd5\u63a7\u5236\u53f0\u3001\u67e5\u770b\u53d8\u91cf\u548c\u5806\u6808\u4fe1\u606f<\/strong>\u662f\u8c03\u8bd5Python\u4ee3\u7801\u7684\u6838\u5fc3\u6b65\u9aa4\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u901a\u8fc7\u8fd9\u4e9b\u6b65\u9aa4\u5728VS Code\u4e2d\u8c03\u8bd5Python\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u5b89\u88c5Python\u6269\u5c55<\/h3>\n<\/p>\n<p><p>\u8981\u5728VS Code\u4e2d\u8c03\u8bd5Python\u4ee3\u7801\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5Python\u6269\u5c55\u3002<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00VS Code\uff0c\u70b9\u51fb\u5de6\u4fa7\u6d3b\u52a8\u680f\u4e2d\u7684\u6269\u5c55\u56fe\u6807\uff08\u56db\u4e2a\u65b9\u5757\u53e0\u5728\u4e00\u8d77\u7684\u56fe\u6807\uff09\u3002<\/li>\n<li>\u5728\u6269\u5c55\u5546\u5e97\u4e2d\u641c\u7d22\u201cPython\u201d\uff0c\u627e\u5230\u7531Microsoft\u53d1\u5e03\u7684Python\u6269\u5c55\u5e76\u70b9\u51fb\u201c\u5b89\u88c5\u201d\u6309\u94ae\u3002<\/li>\n<li>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u91cd\u542fVS Code\u3002<\/li>\n<\/ol>\n<p><h3>\u4e8c\u3001\u914d\u7f6elaunch.json\u6587\u4ef6<\/h3>\n<\/p>\n<p><p>\u914d\u7f6elaunch.json\u6587\u4ef6\u662f\u4e3a\u4e86\u544a\u8bc9VS Code\u5982\u4f55\u542f\u52a8\u548c\u8c03\u8bd5Python\u7a0b\u5e8f\u3002<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u4f60\u8981\u8c03\u8bd5\u7684Python\u9879\u76ee\u3002<\/li>\n<li>\u5728\u5de6\u4fa7\u6d3b\u52a8\u680f\u4e2d\u70b9\u51fb\u201c\u8fd0\u884c\u548c\u8c03\u8bd5\u201d\uff08\u5c0f\u866b\u5b50\u56fe\u6807\uff09\u3002<\/li>\n<li>\u70b9\u51fb\u9876\u90e8\u7684\u201c\u521b\u5efalaunch.json\u6587\u4ef6\u201d\u6309\u94ae\uff0c\u7136\u540e\u9009\u62e9\u201cPython\u201d\u3002<\/li>\n<li>VS Code\u4f1a\u81ea\u52a8\u751f\u6210\u4e00\u4e2alaunch.json\u6587\u4ef6\uff0c\u5305\u542b\u4e00\u4e9b\u57fa\u672c\u7684\u8c03\u8bd5\u914d\u7f6e\u3002<\/li>\n<\/ol>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u7b80\u5355\u7684launch.json\u914d\u7f6e\u793a\u4f8b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-json\">{<\/p>\n<p>    &quot;version&quot;: &quot;0.2.0&quot;,<\/p>\n<p>    &quot;configurations&quot;: [<\/p>\n<p>        {<\/p>\n<p>            &quot;name&quot;: &quot;Python: Current File&quot;,<\/p>\n<p>            &quot;type&quot;: &quot;python&quot;,<\/p>\n<p>            &quot;request&quot;: &quot;launch&quot;,<\/p>\n<p>            &quot;program&quot;: &quot;${file}&quot;,<\/p>\n<p>            &quot;console&quot;: &quot;integratedTerminal&quot;<\/p>\n<p>        }<\/p>\n<p>    ]<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u914d\u7f6e\u8868\u793a\u5c06\u8c03\u8bd5\u5f53\u524d\u6253\u5f00\u7684Python\u6587\u4ef6\uff0c\u5e76\u5728\u96c6\u6210\u7ec8\u7aef\u4e2d\u8fd0\u884c\u3002<\/p>\n<\/p>\n<p><h3>\u4e09\u3001\u8bbe\u7f6e\u65ad\u70b9<\/h3>\n<\/p>\n<p><p>\u8bbe\u7f6e\u65ad\u70b9\u662f\u8c03\u8bd5\u4ee3\u7801\u65f6\u7684\u5173\u952e\u6b65\u9aa4\u3002\u65ad\u70b9\u8ba9\u4f60\u80fd\u591f\u6682\u505c\u4ee3\u7801\u7684\u6267\u884c\uff0c\u4ee5\u4fbf\u68c0\u67e5\u5f53\u524d\u7684\u72b6\u6001\u548c\u53d8\u91cf\u3002<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u4f60\u8981\u8c03\u8bd5\u7684Python\u6587\u4ef6\u3002<\/li>\n<li>\u5728\u884c\u53f7\u5de6\u4fa7\u7684\u7070\u8272\u533a\u57df\u70b9\u51fb\uff0c\u6dfb\u52a0\u4e00\u4e2a\u7ea2\u8272\u7684\u5706\u70b9\uff0c\u5373\u8bbe\u7f6e\u4e00\u4e2a\u65ad\u70b9\u3002<\/li>\n<li>\u4f60\u53ef\u4ee5\u5728\u591a\u4e2a\u4f4d\u7f6e\u8bbe\u7f6e\u65ad\u70b9\uff0c\u4ee5\u4fbf\u66f4\u597d\u5730\u68c0\u67e5\u4ee3\u7801\u7684\u6267\u884c\u60c5\u51b5\u3002<\/li>\n<\/ol>\n<p><h3>\u56db\u3001\u4f7f\u7528\u8c03\u8bd5\u63a7\u5236\u53f0<\/h3>\n<\/p>\n<p><p>\u8c03\u8bd5\u63a7\u5236\u53f0\u5141\u8bb8\u4f60\u5728\u7a0b\u5e8f\u6682\u505c\u65f6\u6267\u884c\u4efb\u610f\u7684Python\u4ee3\u7801\uff0c\u4ee5\u68c0\u67e5\u53d8\u91cf\u548c\u72b6\u6001\u3002<\/p>\n<\/p>\n<ol>\n<li>\u542f\u52a8\u8c03\u8bd5\u4f1a\u8bdd\u3002\u70b9\u51fb\u5de6\u4fa7\u6d3b\u52a8\u680f\u4e2d\u7684\u201c\u8fd0\u884c\u548c\u8c03\u8bd5\u201d\u56fe\u6807\uff0c\u7136\u540e\u70b9\u51fb\u201c\u8fd0\u884c\u548c\u8c03\u8bd5\u201d\u6309\u94ae\u3002<\/li>\n<li>\u5f53\u7a0b\u5e8f\u8fd0\u884c\u5230\u65ad\u70b9\u4f4d\u7f6e\u65f6\u4f1a\u6682\u505c\uff0c\u6b64\u65f6\u8c03\u8bd5\u63a7\u5236\u53f0\u4f1a\u81ea\u52a8\u6253\u5f00\u3002<\/li>\n<li>\u5728\u8c03\u8bd5\u63a7\u5236\u53f0\u4e2d\uff0c\u4f60\u53ef\u4ee5\u8f93\u5165\u4efb\u610fPython\u4ee3\u7801\u6765\u68c0\u67e5\u53d8\u91cf\u548c\u72b6\u6001\uff0c\u4f8b\u5982<code>print(variable_name)<\/code>\u3002<\/li>\n<\/ol>\n<p><h3>\u4e94\u3001\u67e5\u770b\u53d8\u91cf\u548c\u5806\u6808\u4fe1\u606f<\/h3>\n<\/p>\n<p><p>\u8c03\u8bd5\u65f6\uff0c\u67e5\u770b\u53d8\u91cf\u548c\u503c\u662f\u7406\u89e3\u7a0b\u5e8f\u72b6\u6001\u7684\u5173\u952e\u6b65\u9aa4\u3002<\/p>\n<\/p>\n<ol>\n<li>\u5f53\u7a0b\u5e8f\u6682\u505c\u5728\u65ad\u70b9\u4f4d\u7f6e\u65f6\uff0cVS Code\u7684\u5de6\u4fa7\u6d3b\u52a8\u680f\u4f1a\u663e\u793a\u201c\u53d8\u91cf\u201d\u548c\u201c\u8c03\u7528\u5806\u6808\u201d\u9762\u677f\u3002<\/li>\n<li>\u5728\u201c\u53d8\u91cf\u201d\u9762\u677f\u4e2d\uff0c\u53ef\u4ee5\u67e5\u770b\u5f53\u524d\u4f5c\u7528\u57df\u5185\u6240\u6709\u53d8\u91cf\u7684\u503c\u3002<\/li>\n<li>\u5728\u201c\u8c03\u7528\u5806\u6808\u201d\u9762\u677f\u4e2d\uff0c\u53ef\u4ee5\u67e5\u770b\u5f53\u524d\u7a0b\u5e8f\u7684\u8c03\u7528\u5806\u6808\u4fe1\u606f\uff0c\u4e86\u89e3\u7a0b\u5e8f\u662f\u5982\u4f55\u6267\u884c\u5230\u5f53\u524d\u4f4d\u7f6e\u7684\u3002<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u53ef\u4ee5\u5728VS Code\u4e2d\u65b9\u4fbf\u5730\u8c03\u8bd5Python\u4ee3\u7801\uff0c\u68c0\u67e5\u548c\u4fee\u6539\u53d8\u91cf\uff0c\u67e5\u770b\u7a0b\u5e8f\u7684\u6267\u884c\u6d41\u7a0b\uff0c\u627e\u5230\u5e76\u4fee\u590d\u95ee\u9898\u3002<\/p>\n<\/p>\n<p><h3>\u516d\u3001\u914d\u7f6e\u865a\u62df\u73af\u5883<\/h3>\n<\/p>\n<p><p>\u5728\u5f00\u53d1Python\u9879\u76ee\u65f6\uff0c\u4f7f\u7528\u865a\u62df\u73af\u5883\uff08Virtual Environment\uff09\u53ef\u4ee5\u5e2e\u52a9\u4f60\u9694\u79bb\u9879\u76ee\u7684\u4f9d\u8d56\uff0c\u907f\u514d\u4e0d\u540c\u9879\u76ee\u4e4b\u95f4\u7684\u4f9d\u8d56\u51b2\u7a81\u3002\u5728VS Code\u4e2d\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u914d\u7f6e\u548c\u4f7f\u7528\u865a\u62df\u73af\u5883\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efa\u865a\u62df\u73af\u5883<\/strong>\uff1a\u6253\u5f00\u7ec8\u7aef\uff08\u53ef\u4ee5\u4f7f\u7528VS Code\u7684\u96c6\u6210\u7ec8\u7aef\uff09\uff0c\u5728\u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python -m venv venv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4f1a\u5728\u9879\u76ee\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>venv<\/code>\u7684\u865a\u62df\u73af\u5883\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/strong>\uff1a<\/p>\n<\/p>\n<ul>\n<li>\u5728Windows\u7cfb\u7edf\u4e0a\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a\n<pre><code class=\"language-bash\">.\\venv\\Scripts\\activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\u5728macOS\u548cLinux\u7cfb\u7edf\u4e0a\uff0c\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u6fc0\u6d3b\u865a\u62df\u73af\u5883\uff1a\n<pre><code class=\"language-bash\">source venv\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5728VS Code\u4e2d\u9009\u62e9\u865a\u62df\u73af\u5883<\/strong>\uff1a\u6253\u5f00VS Code\uff0c\u6309\u4e0b<code>Ctrl+Shift+P<\/code>\u6253\u5f00\u547d\u4ee4\u9762\u677f\uff0c\u8f93\u5165\u5e76\u9009\u62e9<code>Python: Select Interpreter<\/code>\u3002\u5728\u5f39\u51fa\u7684\u5217\u8868\u4e2d\u9009\u62e9\u4f60\u521b\u5efa\u7684\u865a\u62df\u73af\u5883\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e03\u3001\u4f7f\u7528\u65ad\u70b9\u6761\u4ef6<\/h3>\n<\/p>\n<p><p>\u6709\u65f6\u4f60\u53ef\u80fd\u5e0c\u671b\u5728\u7279\u5b9a\u6761\u4ef6\u4e0b\u624d\u6682\u505c\u7a0b\u5e8f\u6267\u884c\uff0c\u8fd9\u65f6\u53ef\u4ee5\u4f7f\u7528\u65ad\u70b9\u6761\u4ef6\u3002<\/p>\n<\/p>\n<ol>\n<li>\u53f3\u952e\u70b9\u51fb\u65ad\u70b9\uff0c\u9009\u62e9\u201c\u7f16\u8f91\u65ad\u70b9\u201d\u3002<\/li>\n<li>\u5728\u5f39\u51fa\u7684\u8f93\u5165\u6846\u4e2d\u8f93\u5165\u6761\u4ef6\u8868\u8fbe\u5f0f\uff0c\u4f8b\u5982<code>variable_name == &#39;specific_value&#39;<\/code>\u3002<\/li>\n<li>\u5f53\u6761\u4ef6\u4e3a\u771f\u65f6\uff0c\u7a0b\u5e8f\u624d\u4f1a\u6682\u505c\u5728\u8be5\u65ad\u70b9\u4f4d\u7f6e\u3002<\/li>\n<\/ol>\n<p><h3>\u516b\u3001\u8c03\u8bd5\u5355\u5143\u6d4b\u8bd5<\/h3>\n<\/p>\n<p><p>\u5728VS Code\u4e2d\u8c03\u8bd5\u5355\u5143\u6d4b\u8bd5\u975e\u5e38\u65b9\u4fbf\uff0c\u4ee5\u4e0b\u662f\u5177\u4f53\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5\u6d4b\u8bd5\u6846\u67b6<\/strong>\uff1a\u786e\u4fdd\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86Python\u7684\u6d4b\u8bd5\u6846\u67b6\uff0c\u5982<code>unittest<\/code>\u3001<code>pytest<\/code>\u6216<code>nose<\/code>\u3002\u53ef\u4ee5\u5728\u865a\u62df\u73af\u5883\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pytest<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u914d\u7f6e\u6d4b\u8bd5\u6846\u67b6<\/strong>\uff1a\u5728VS Code\u4e2d\u6309\u4e0b<code>Ctrl+Shift+P<\/code>\u6253\u5f00\u547d\u4ee4\u9762\u677f\uff0c\u8f93\u5165\u5e76\u9009\u62e9<code>Python: Configure Tests<\/code>\u3002\u9009\u62e9\u4f60\u4f7f\u7528\u7684\u6d4b\u8bd5\u6846\u67b6\uff0c\u5982<code>pytest<\/code>\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8fd0\u884c\u548c\u8c03\u8bd5\u6d4b\u8bd5<\/strong>\uff1a\u5728\u6d4b\u8bd5\u6587\u4ef6\u4e2d\u53f3\u952e\u70b9\u51fb\u5355\u5143\u6d4b\u8bd5\u51fd\u6570\uff0c\u9009\u62e9\u201cDebug Test\u201d\u5373\u53ef\u5f00\u59cb\u8c03\u8bd5\u5355\u5143\u6d4b\u8bd5\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e5d\u3001\u4f7f\u7528\u65e5\u5fd7\u8bb0\u5f55<\/h3>\n<\/p>\n<p><p>\u5728\u8c03\u8bd5\u8fc7\u7a0b\u4e2d\uff0c\u4f7f\u7528\u65e5\u5fd7\u8bb0\u5f55\uff08Logging\uff09\u53ef\u4ee5\u5e2e\u52a9\u4f60\u8bb0\u5f55\u548c\u8ffd\u8e2a\u7a0b\u5e8f\u7684\u6267\u884c\u8fc7\u7a0b\u3002Python\u5185\u7f6e\u4e86<code>logging<\/code>\u6a21\u5757\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u8bb0\u5f55\u65e5\u5fd7\u4fe1\u606f\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p>\u5728\u4f60\u7684Python\u4ee3\u7801\u4e2d\u5bfc\u5165<code>logging<\/code>\u6a21\u5757\u5e76\u8fdb\u884c\u914d\u7f6e\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import logging<\/p>\n<p>logging.basicConfig(level=logging.DEBUG, format=&#39;%(asctime)s - %(levelname)s - %(message)s&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u4f7f\u7528<code>logging<\/code>\u8bb0\u5f55\u65e5\u5fd7\u4fe1\u606f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">logging.debug(&#39;This is a debug message&#39;)<\/p>\n<p>logging.info(&#39;This is an info message&#39;)<\/p>\n<p>logging.warning(&#39;This is a warning message&#39;)<\/p>\n<p>logging.error(&#39;This is an error message&#39;)<\/p>\n<p>logging.critical(&#39;This is a critical message&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>\u8fd0\u884c\u7a0b\u5e8f\u65f6\uff0c\u65e5\u5fd7\u4fe1\u606f\u4f1a\u663e\u793a\u5728\u7ec8\u7aef\u6216\u65e5\u5fd7\u6587\u4ef6\u4e2d\uff0c\u5e2e\u52a9\u4f60\u4e86\u89e3\u7a0b\u5e8f\u7684\u6267\u884c\u60c5\u51b5\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u5341\u3001\u8fdc\u7a0b\u8c03\u8bd5<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u8c03\u8bd5\u8fd0\u884c\u5728\u8fdc\u7a0b\u670d\u52a1\u5668\u4e0a\u7684Python\u4ee3\u7801\u3002VS Code\u652f\u6301\u8fdc\u7a0b\u8c03\u8bd5\uff0c\u4ee5\u4e0b\u662f\u5177\u4f53\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5728\u8fdc\u7a0b\u670d\u52a1\u5668\u4e0a\u5b89\u88c5ptvsd<\/strong>\uff1a\u5728\u8fdc\u7a0b\u670d\u52a1\u5668\u7684Python\u73af\u5883\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5<code>ptvsd<\/code>\u6a21\u5757\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install ptvsd<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5728\u4ee3\u7801\u4e2d\u6dfb\u52a0\u8c03\u8bd5\u4ee3\u7801<\/strong>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import ptvsd<\/p>\n<p>ptvsd.enable_attach(address=(&#39;0.0.0.0&#39;, 5678))<\/p>\n<p>ptvsd.w<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>t_for_attach()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u914d\u7f6eVS Code\u8fdb\u884c\u8fdc\u7a0b\u8c03\u8bd5<\/strong>\uff1a\u5728\u672c\u5730VS Code\u4e2d\u6253\u5f00<code>launch.json<\/code>\u6587\u4ef6\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-json\">{<\/p>\n<p>    &quot;name&quot;: &quot;Python: Remote Attach&quot;,<\/p>\n<p>    &quot;type&quot;: &quot;python&quot;,<\/p>\n<p>    &quot;request&quot;: &quot;attach&quot;,<\/p>\n<p>    &quot;host&quot;: &quot;remote-server-ip&quot;,<\/p>\n<p>    &quot;port&quot;: 5678,<\/p>\n<p>    &quot;pathMappings&quot;: [<\/p>\n<p>        {<\/p>\n<p>            &quot;localRoot&quot;: &quot;${workspaceFolder}&quot;,<\/p>\n<p>            &quot;remoteRoot&quot;: &quot;\/path\/to\/remote\/project&quot;<\/p>\n<p>        }<\/p>\n<p>    ]<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u542f\u52a8\u8fdc\u7a0b\u8c03\u8bd5\u4f1a\u8bdd<\/strong>\uff1a\u5728\u672c\u5730VS Code\u4e2d\u9009\u62e9\u201cPython: Remote Attach\u201d\u914d\u7f6e\uff0c\u70b9\u51fb\u201c\u8fd0\u884c\u548c\u8c03\u8bd5\u201d\u6309\u94ae\uff0c\u5373\u53ef\u8fde\u63a5\u5230\u8fdc\u7a0b\u670d\u52a1\u5668\u8fdb\u884c\u8c03\u8bd5\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u5341\u4e00\u3001\u4f7f\u7528\u8c03\u8bd5\u914d\u7f6e\u6587\u4ef6<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u4e3a\u4e0d\u540c\u7684\u8c03\u8bd5\u573a\u666f\u521b\u5efa\u591a\u4e2a\u8c03\u8bd5\u914d\u7f6e\u6587\u4ef6\u3002\u53ef\u4ee5\u5728<code>launch.json<\/code>\u4e2d\u6dfb\u52a0\u591a\u4e2a\u914d\u7f6e\uff0c\u65b9\u4fbf\u9009\u62e9\u548c\u5207\u6362\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-json\">{<\/p>\n<p>    &quot;version&quot;: &quot;0.2.0&quot;,<\/p>\n<p>    &quot;configurations&quot;: [<\/p>\n<p>        {<\/p>\n<p>            &quot;name&quot;: &quot;Python: Current File&quot;,<\/p>\n<p>            &quot;type&quot;: &quot;python&quot;,<\/p>\n<p>            &quot;request&quot;: &quot;launch&quot;,<\/p>\n<p>            &quot;program&quot;: &quot;${file}&quot;,<\/p>\n<p>            &quot;console&quot;: &quot;integratedTerminal&quot;<\/p>\n<p>        },<\/p>\n<p>        {<\/p>\n<p>            &quot;name&quot;: &quot;Python: Module&quot;,<\/p>\n<p>            &quot;type&quot;: &quot;python&quot;,<\/p>\n<p>            &quot;request&quot;: &quot;launch&quot;,<\/p>\n<p>            &quot;module&quot;: &quot;module_name&quot;,<\/p>\n<p>            &quot;console&quot;: &quot;integratedTerminal&quot;<\/p>\n<p>        },<\/p>\n<p>        {<\/p>\n<p>            &quot;name&quot;: &quot;Python: Django&quot;,<\/p>\n<p>            &quot;type&quot;: &quot;python&quot;,<\/p>\n<p>            &quot;request&quot;: &quot;launch&quot;,<\/p>\n<p>            &quot;program&quot;: &quot;${workspaceFolder}\/manage.py&quot;,<\/p>\n<p>            &quot;args&quot;: [&quot;runserver&quot;],<\/p>\n<p>            &quot;django&quot;: true<\/p>\n<p>        }<\/p>\n<p>    ]<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e9b\u914d\u7f6e\u6587\u4ef6\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5728\u4e0d\u540c\u7684\u8c03\u8bd5\u573a\u666f\u4e0b\u5feb\u901f\u5207\u6362\u548c\u8fd0\u884c\u8c03\u8bd5\u4f1a\u8bdd\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u4e8c\u3001\u8c03\u8bd5\u591a\u7ebf\u7a0b\u4ee3\u7801<\/h3>\n<\/p>\n<p><p>\u8c03\u8bd5\u591a\u7ebf\u7a0b\u4ee3\u7801\u53ef\u80fd\u4f1a\u6bd4\u8f83\u590d\u6742\uff0c\u4f46VS Code\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u8c03\u8bd5\u529f\u80fd\uff0c\u5e2e\u52a9\u4f60\u5206\u6790\u591a\u7ebf\u7a0b\u7a0b\u5e8f\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u8bbe\u7f6e\u65ad\u70b9<\/strong>\uff1a\u5728\u591a\u7ebf\u7a0b\u4ee3\u7801\u4e2d\u8bbe\u7f6e\u65ad\u70b9\uff0cVS Code\u4f1a\u5728\u4efb\u610f\u4e00\u4e2a\u7ebf\u7a0b\u8fd0\u884c\u5230\u65ad\u70b9\u4f4d\u7f6e\u65f6\u6682\u505c\u3002<\/li>\n<li><strong>\u67e5\u770b\u7ebf\u7a0b\u4fe1\u606f<\/strong>\uff1a\u5728\u8c03\u8bd5\u8fc7\u7a0b\u4e2d\uff0cVS Code\u7684\u201c\u8c03\u7528\u5806\u6808\u201d\u9762\u677f\u4f1a\u663e\u793a\u6240\u6709\u7ebf\u7a0b\u7684\u4fe1\u606f\u3002\u4f60\u53ef\u4ee5\u9009\u62e9\u4e0d\u540c\u7684\u7ebf\u7a0b\uff0c\u67e5\u770b\u5404\u81ea\u7684\u8c03\u7528\u5806\u6808\u548c\u53d8\u91cf\u3002<\/li>\n<li><strong>\u4f7f\u7528\u8c03\u8bd5\u63a7\u5236\u53f0<\/strong>\uff1a\u5728\u8c03\u8bd5\u63a7\u5236\u53f0\u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u7ebf\u7a0b\u76f8\u5173\u7684\u547d\u4ee4\uff0c\u4f8b\u5982<code>threading.enumerate()<\/code>\uff0c\u67e5\u770b\u5f53\u524d\u8fd0\u884c\u7684\u6240\u6709\u7ebf\u7a0b\u3002<\/li>\n<\/ol>\n<p><h3>\u5341\u4e09\u3001\u8c03\u8bd5\u5f02\u6b65\u4ee3\u7801<\/h3>\n<\/p>\n<p><p>\u5f02\u6b65\u7f16\u7a0b\u5728Python\u4e2d\u8d8a\u6765\u8d8a\u6d41\u884c\uff0c\u5c24\u5176\u662f\u5728\u5904\u7406I\/O\u5bc6\u96c6\u578b\u4efb\u52a1\u65f6\u3002\u8c03\u8bd5\u5f02\u6b65\u4ee3\u7801\u4e0e\u8c03\u8bd5\u666e\u901a\u4ee3\u7801\u6709\u6240\u4e0d\u540c\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u8bbe\u7f6e\u65ad\u70b9<\/strong>\uff1a\u5728\u5f02\u6b65\u51fd\u6570\u4e2d\u8bbe\u7f6e\u65ad\u70b9\uff0cVS Code\u4f1a\u5728\u5f02\u6b65\u51fd\u6570\u6267\u884c\u5230\u65ad\u70b9\u4f4d\u7f6e\u65f6\u6682\u505c\u3002<\/li>\n<li><strong>\u67e5\u770b\u4efb\u52a1\u4fe1\u606f<\/strong>\uff1a\u5728\u8c03\u8bd5\u8fc7\u7a0b\u4e2d\uff0cVS Code\u7684\u201c\u8c03\u7528\u5806\u6808\u201d\u9762\u677f\u4f1a\u663e\u793a\u5f53\u524d\u6b63\u5728\u6267\u884c\u7684\u5f02\u6b65\u4efb\u52a1\u3002\u4f60\u53ef\u4ee5\u67e5\u770b\u5f02\u6b65\u4efb\u52a1\u7684\u8c03\u7528\u5806\u6808\u548c\u53d8\u91cf\u3002<\/li>\n<li><strong>\u4f7f\u7528\u8c03\u8bd5\u63a7\u5236\u53f0<\/strong>\uff1a\u5728\u8c03\u8bd5\u63a7\u5236\u53f0\u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u5f02\u6b65\u76f8\u5173\u7684\u547d\u4ee4\uff0c\u4f8b\u5982<code>await<\/code>\u8868\u8fbe\u5f0f\uff0c\u6765\u68c0\u67e5\u548c\u64cd\u4f5c\u5f02\u6b65\u4efb\u52a1\u3002<\/li>\n<\/ol>\n<p><h3>\u5341\u56db\u3001\u8c03\u8bd5\u73af\u5883\u53d8\u91cf<\/h3>\n<\/p>\n<p><p>\u5728\u8c03\u8bd5\u8fc7\u7a0b\u4e2d\uff0c\u6709\u65f6\u9700\u8981\u8bbe\u7f6e\u548c\u4f7f\u7528\u73af\u5883\u53d8\u91cf\uff0c\u4f8b\u5982\u914d\u7f6e\u6587\u4ef6\u8def\u5f84\u3001API\u5bc6\u94a5\u7b49\u3002\u4f60\u53ef\u4ee5\u5728<code>launch.json<\/code>\u4e2d\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-json\">{<\/p>\n<p>    &quot;name&quot;: &quot;Python: Current File&quot;,<\/p>\n<p>    &quot;type&quot;: &quot;python&quot;,<\/p>\n<p>    &quot;request&quot;: &quot;launch&quot;,<\/p>\n<p>    &quot;program&quot;: &quot;${file}&quot;,<\/p>\n<p>    &quot;console&quot;: &quot;integratedTerminal&quot;,<\/p>\n<p>    &quot;env&quot;: {<\/p>\n<p>        &quot;ENV_VAR_NAME&quot;: &quot;value&quot;<\/p>\n<p>    }<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u914d\u7f6e\u4e2d\uff0c<code>ENV_VAR_NAME<\/code>\u662f\u73af\u5883\u53d8\u91cf\u7684\u540d\u79f0\uff0c<code>value<\/code>\u662f\u73af\u5883\u53d8\u91cf\u7684\u503c\u3002\u7a0b\u5e8f\u5728\u8c03\u8bd5\u8fc7\u7a0b\u4e2d\u4f1a\u8bfb\u53d6\u548c\u4f7f\u7528\u8fd9\u4e9b\u73af\u5883\u53d8\u91cf\u3002<\/p>\n<\/p>\n<p><h3>\u5341\u4e94\u3001\u8c03\u8bd5\u5185\u7f6e\u6a21\u5757\u548c\u7b2c\u4e09\u65b9\u5e93<\/h3>\n<\/p>\n<p><p>\u6709\u65f6\u4f60\u53ef\u80fd\u9700\u8981\u8c03\u8bd5Python\u7684\u5185\u7f6e\u6a21\u5757\u6216\u7b2c\u4e09\u65b9\u5e93\u7684\u4ee3\u7801\u3002VS Code\u5141\u8bb8\u4f60\u65b9\u4fbf\u5730\u8c03\u8bd5\u8fd9\u4e9b\u4ee3\u7801\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u8bbe\u7f6e\u65ad\u70b9<\/strong>\uff1a\u5728\u5185\u7f6e\u6a21\u5757\u6216\u7b2c\u4e09\u65b9\u5e93\u7684\u4ee3\u7801\u4e2d\u8bbe\u7f6e\u65ad\u70b9\u3002\u4f8b\u5982\uff0c\u627e\u5230\u5e93\u7684\u6e90\u4ee3\u7801\u6587\u4ef6\uff0c\u5728\u9700\u8981\u8c03\u8bd5\u7684\u4f4d\u7f6e\u8bbe\u7f6e\u65ad\u70b9\u3002<\/li>\n<li><strong>\u914d\u7f6e\u8c03\u8bd5\u9009\u9879<\/strong>\uff1a\u5728<code>launch.json<\/code>\u4e2d\u6dfb\u52a0<code>justMyCode<\/code>\u9009\u9879\uff0c\u5e76\u5c06\u5176\u8bbe\u7f6e\u4e3a<code>false<\/code>\uff0c\u5141\u8bb8\u8c03\u8bd5\u975e\u7528\u6237\u4ee3\u7801\u3002\n<pre><code class=\"language-json\">{<\/p>\n<p>    &quot;name&quot;: &quot;Python: Current File&quot;,<\/p>\n<p>    &quot;type&quot;: &quot;python&quot;,<\/p>\n<p>    &quot;request&quot;: &quot;launch&quot;,<\/p>\n<p>    &quot;program&quot;: &quot;${file}&quot;,<\/p>\n<p>    &quot;console&quot;: &quot;integratedTerminal&quot;,<\/p>\n<p>    &quot;justMyCode&quot;: false<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li><strong>\u542f\u52a8\u8c03\u8bd5\u4f1a\u8bdd<\/strong>\uff1a\u542f\u52a8\u8c03\u8bd5\u4f1a\u8bdd\uff0c\u7a0b\u5e8f\u8fd0\u884c\u5230\u65ad\u70b9\u4f4d\u7f6e\u65f6\u4f1a\u6682\u505c\uff0c\u4f60\u53ef\u4ee5\u68c0\u67e5\u548c\u8c03\u8bd5\u5185\u7f6e\u6a21\u5757\u6216\u7b2c\u4e09\u65b9\u5e93\u7684\u4ee3\u7801\u3002<\/li>\n<\/ol>\n<p><h3>\u5341\u516d\u3001\u8c03\u8bd5\u6027\u80fd\u95ee\u9898<\/h3>\n<\/p>\n<p><p>\u8c03\u8bd5\u6027\u80fd\u95ee\u9898\u662f\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u5e38\u89c1\u7684\u9700\u6c42\u3002\u901a\u8fc7\u6027\u80fd\u5206\u6790\uff08Profiling\uff09\uff0c\u4f60\u53ef\u4ee5\u627e\u5230\u7a0b\u5e8f\u4e2d\u7684\u6027\u80fd\u74f6\u9888\uff0c\u5e76\u8fdb\u884c\u4f18\u5316\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u4f7f\u7528cProfile\u6a21\u5757<\/strong>\uff1aPython\u5185\u7f6e\u4e86<code>cProfile<\/code>\u6a21\u5757\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u8fdb\u884c\u6027\u80fd\u5206\u6790\u3002\u4f60\u53ef\u4ee5\u5728\u4ee3\u7801\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a\n<pre><code class=\"language-python\">import cProfile<\/p>\n<p>cProfile.run(&#39;main()&#39;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li><strong>\u67e5\u770b\u6027\u80fd\u62a5\u544a<\/strong>\uff1a\u8fd0\u884c\u7a0b\u5e8f\u540e\uff0c<code>cProfile<\/code>\u4f1a\u751f\u6210\u6027\u80fd\u62a5\u544a\uff0c\u663e\u793a\u51fd\u6570\u7684\u8c03\u7528\u6b21\u6570\u548c\u6267\u884c\u65f6\u95f4\u3002\u4f60\u53ef\u4ee5\u6839\u636e\u62a5\u544a\u4e2d\u7684\u4fe1\u606f\u627e\u5230\u6027\u80fd\u74f6\u9888\u3002<\/li>\n<li><strong>\u4f18\u5316\u4ee3\u7801<\/strong>\uff1a\u6839\u636e\u6027\u80fd\u62a5\u544a\u4e2d\u7684\u4fe1\u606f\uff0c\u627e\u5230\u6267\u884c\u65f6\u95f4\u957f\u7684\u51fd\u6570\u548c\u4ee3\u7801\u6bb5\uff0c\u8fdb\u884c\u4f18\u5316\u3002\u4f8b\u5982\uff0c\u4f7f\u7528\u66f4\u9ad8\u6548\u7684\u6570\u636e\u7ed3\u6784\u548c\u7b97\u6cd5\uff0c\u51cf\u5c11\u4e0d\u5fc5\u8981\u7684\u8ba1\u7b97\u7b49\u3002<\/li>\n<\/ol>\n<p><h3>\u5341\u4e03\u3001\u8c03\u8bd5\u5185\u5b58\u95ee\u9898<\/h3>\n<\/p>\n<p><p>\u5185\u5b58\u95ee\u9898\u4e5f\u662f\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u5e38\u89c1\u7684\u9700\u6c42\uff0c\u7279\u522b\u662f\u5728\u5904\u7406\u5927\u6570\u636e\u6216\u957f\u65f6\u95f4\u8fd0\u884c\u7684\u7a0b\u5e8f\u65f6\u3002\u901a\u8fc7\u5185\u5b58\u5206\u6790\uff08Memory Profiling\uff09\uff0c\u4f60\u53ef\u4ee5\u627e\u5230\u5185\u5b58\u6cc4\u6f0f\u548c\u4f18\u5316\u5185\u5b58\u4f7f\u7528\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4f7f\u7528memory_profiler\u6a21\u5757<\/strong>\uff1a<code>memory_profiler<\/code>\u662f\u4e00\u4e2a\u7b2c\u4e09\u65b9\u6a21\u5757\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u8fdb\u884c\u5185\u5b58\u5206\u6790\u3002\u4f60\u53ef\u4ee5\u5728\u865a\u62df\u73af\u5883\u4e2d\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install memory_profiler<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5728\u4ee3\u7801\u4e2d\u4f7f\u7528memory_profiler<\/strong>\uff1a\u5728\u9700\u8981\u5206\u6790\u5185\u5b58\u7684\u4ee3\u7801\u6bb5\u6dfb\u52a0<code>@profile<\/code>\u88c5\u9970\u5668\uff0c\u5e76\u8fd0\u884c\u7a0b\u5e8f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from memory_profiler import profile<\/p>\n<p>@profile<\/p>\n<p>def main():<\/p>\n<p>    # Your code here<\/p>\n<p>if __name__ == &#39;__main__&#39;:<\/p>\n<p>    main()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u67e5\u770b\u5185\u5b58\u62a5\u544a<\/strong>\uff1a\u8fd0\u884c\u7a0b\u5e8f\u540e\uff0c<code>memory_profiler<\/code>\u4f1a\u751f\u6210\u5185\u5b58\u62a5\u544a\uff0c\u663e\u793a\u5404\u4e2a\u4ee3\u7801\u6bb5\u7684\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u3002\u4f60\u53ef\u4ee5\u6839\u636e\u62a5\u544a\u4e2d\u7684\u4fe1\u606f\u627e\u5230\u5185\u5b58\u6cc4\u6f0f\u548c\u4f18\u5316\u5185\u5b58\u4f7f\u7528\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u5341\u516b\u3001\u8c03\u8bd5\u591a\u8fdb\u7a0b\u4ee3\u7801<\/h3>\n<\/p>\n<p><p>\u8c03\u8bd5\u591a\u8fdb\u7a0b\u4ee3\u7801\u6bd4\u8c03\u8bd5\u5355\u7ebf\u7a0b\u4ee3\u7801\u66f4\u590d\u6742\uff0c\u4f46VS Code\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u8c03\u8bd5\u529f\u80fd\uff0c\u5e2e\u52a9\u4f60\u5206\u6790\u591a\u8fdb\u7a0b\u7a0b\u5e8f\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u8bbe\u7f6e\u65ad\u70b9<\/strong>\uff1a\u5728\u591a\u8fdb\u7a0b\u4ee3\u7801\u4e2d\u8bbe\u7f6e\u65ad\u70b9\uff0cVS Code\u4f1a\u5728\u4efb\u610f\u4e00\u4e2a\u8fdb\u7a0b\u8fd0\u884c\u5230\u65ad\u70b9\u4f4d\u7f6e\u65f6\u6682\u505c\u3002<\/li>\n<li><strong>\u67e5\u770b\u8fdb\u7a0b\u4fe1\u606f<\/strong>\uff1a\u5728\u8c03\u8bd5\u8fc7\u7a0b\u4e2d\uff0cVS Code\u7684\u201c\u8c03\u7528\u5806\u6808\u201d\u9762\u677f\u4f1a\u663e\u793a\u6240\u6709\u8fdb\u7a0b\u7684\u4fe1\u606f\u3002\u4f60\u53ef\u4ee5\u9009\u62e9\u4e0d\u540c\u7684\u8fdb\u7a0b\uff0c\u67e5\u770b\u5404\u81ea\u7684\u8c03\u7528\u5806\u6808\u548c\u53d8\u91cf\u3002<\/li>\n<li><strong>\u4f7f\u7528\u8c03\u8bd5\u63a7\u5236\u53f0<\/strong>\uff1a\u5728\u8c03\u8bd5\u63a7\u5236\u53f0\u4e2d\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u8fdb\u7a0b\u76f8\u5173\u7684\u547d\u4ee4\uff0c\u4f8b\u5982<code>psutil.process_iter()<\/code>\uff0c\u67e5\u770b\u5f53\u524d\u8fd0\u884c\u7684\u6240\u6709\u8fdb\u7a0b\u3002<\/li>\n<\/ol>\n<p><h3>\u5341\u4e5d\u3001\u8c03\u8bd5\u7f51\u7edc\u5e94\u7528<\/h3>\n<\/p>\n<p><p>\u8c03\u8bd5\u7f51\u7edc\u5e94\u7528\uff0c\u5982Web\u5e94\u7528\u548cAPI\uff0c\u662f\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u5e38\u89c1\u7684\u9700\u6c42\u3002\u901a\u8fc7\u8c03\u8bd5\u7f51\u7edc\u8bf7\u6c42\u548c\u54cd\u5e94\uff0c\u4f60\u53ef\u4ee5\u627e\u5230\u548c\u89e3\u51b3\u7f51\u7edc\u5e94\u7528\u4e2d\u7684\u95ee\u9898\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u8bbe\u7f6e\u65ad\u70b9<\/strong>\uff1a\u5728\u5904\u7406\u7f51\u7edc\u8bf7\u6c42\u7684\u4ee3\u7801\u4e2d\u8bbe\u7f6e\u65ad\u70b9\uff0cVS Code\u4f1a\u5728\u5904\u7406\u7f51\u7edc\u8bf7\u6c42\u65f6\u6682\u505c\u3002<\/li>\n<li><strong>\u67e5\u770b\u8bf7\u6c42\u548c\u54cd\u5e94<\/strong>\uff1a\u5728\u8c03\u8bd5\u8fc7\u7a0b\u4e2d\uff0c\u4f7f\u7528\u8c03\u8bd5\u63a7\u5236\u53f0\u6216\u65e5\u5fd7\u8bb0\u5f55\uff0c\u67e5\u770b\u7f51\u7edc\u8bf7\u6c42\u548c\u54cd\u5e94\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u4f8b\u5982\u8bf7\u6c42\u5934\u3001\u8bf7\u6c42\u4f53\u3001\u54cd\u5e94\u5934\u3001\u54cd\u5e94\u4f53\u7b49\u3002<\/li>\n<li><strong>\u4f7f\u7528Postman\u7b49\u5de5\u5177<\/strong>\uff1a\u4f7f\u7528Postman\u7b49\u5de5\u5177\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u53d1\u9001\u548c\u8c03\u8bd5HTTP\u8bf7\u6c42\uff0c\u68c0\u67e5\u8bf7\u6c42\u548c\u54cd\u5e94\u7684\u8be6\u7ec6\u4fe1\u606f\u3002<\/li>\n<\/ol>\n<p><h3>\u4e8c\u5341\u3001\u8c03\u8bd5\u6570\u636e\u5e93\u64cd\u4f5c<\/h3>\n<\/p>\n<p><p>\u8c03\u8bd5\u6570\u636e\u5e93\u64cd\u4f5c\u662f\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u5e38\u89c1\u7684\u9700\u6c42\uff0c\u901a\u8fc7\u8c03\u8bd5\u6570\u636e\u5e93\u67e5\u8be2\u548c\u64cd\u4f5c\uff0c\u4f60\u53ef\u4ee5\u627e\u5230\u548c\u89e3\u51b3\u6570\u636e\u5e93\u76f8\u5173\u7684\u95ee\u9898\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u8bbe\u7f6e\u65ad\u70b9<\/strong>\uff1a\u5728\u5904\u7406\u6570\u636e\u5e93\u64cd\u4f5c\u7684\u4ee3\u7801\u4e2d\u8bbe\u7f6e\u65ad\u70b9\uff0cVS Code\u4f1a\u5728\u6267\u884c\u6570\u636e\u5e93\u67e5\u8be2\u548c\u64cd\u4f5c\u65f6\u6682\u505c\u3002<\/li>\n<li><strong>\u67e5\u770b\u67e5\u8be2\u548c\u7ed3\u679c<\/strong>\uff1a\u5728\u8c03\u8bd5\u8fc7\u7a0b\u4e2d\uff0c\u4f7f\u7528\u8c03\u8bd5\u63a7\u5236\u53f0\u6216\u65e5\u5fd7\u8bb0\u5f55\uff0c\u67e5\u770b\u6570\u636e\u5e93\u67e5\u8be2\u548c\u7ed3\u679c\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u4f8b\u5982\u67e5\u8be2\u8bed\u53e5\u3001\u67e5\u8be2\u53c2\u6570\u3001\u67e5\u8be2\u7ed3\u679c\u7b49\u3002<\/li>\n<li><strong>\u4f7f\u7528\u6570\u636e\u5e93\u7ba1\u7406\u5de5\u5177<\/strong>\uff1a\u4f7f\u7528\u6570\u636e\u5e93\u7ba1\u7406\u5de5\u5177\uff0c\u5982MySQL Workbench\u3001pgAdmin\u7b49\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u6267\u884c\u548c\u8c03\u8bd5\u6570\u636e\u5e93\u67e5\u8be2\uff0c\u68c0\u67e5\u6570\u636e\u5e93\u8868\u548c\u6570\u636e\u7684\u8be6\u7ec6\u4fe1\u606f\u3002<\/li>\n<\/ol>\n<p><p>\u603b\u7ed3\u8d77\u6765\uff0cVS Code\u63d0\u4f9b\u4e86\u5f3a\u5927\u4e14\u7075\u6d3b\u7684\u8c03\u8bd5\u529f\u80fd\uff0c\u901a\u8fc7<strong>\u5b89\u88c5Python\u6269\u5c55\u3001\u914d\u7f6elaunch.json\u6587\u4ef6\u3001\u8bbe\u7f6e\u65ad\u70b9\u3001\u4f7f\u7528\u8c03\u8bd5\u63a7\u5236\u53f0\u3001\u67e5\u770b\u53d8\u91cf\u548c\u5806\u6808\u4fe1\u606f<\/strong>\uff0c\u4f60\u53ef\u4ee5\u65b9\u4fbf\u5730\u8c03\u8bd5Python\u4ee3\u7801\uff0c\u68c0\u67e5\u548c\u4fee\u6539\u53d8\u91cf\uff0c\u67e5\u770b\u7a0b\u5e8f\u7684\u6267\u884c\u6d41\u7a0b\uff0c\u627e\u5230\u5e76\u4fee\u590d\u95ee\u9898\u3002\u540c\u65f6\uff0c\u4f7f\u7528\u865a\u62df\u73af\u5883\u3001\u8fdc\u7a0b\u8c03\u8bd5\u3001\u6027\u80fd\u5206\u6790\u3001\u5185\u5b58\u5206\u6790\u7b49\u9ad8\u7ea7\u529f\u80fd\uff0c\u53ef\u4ee5\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u5f00\u53d1\u548c\u8c03\u8bd5Python\u9879\u76ee\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728VSCode\u4e2d\u914d\u7f6ePython\u8c03\u8bd5\u73af\u5883\uff1f<\/strong><br \/>\u8981\u5728VSCode\u4e2d\u8c03\u8bd5Python\u4ee3\u7801\uff0c\u60a8\u9700\u8981\u786e\u4fdd\u5df2\u5b89\u88c5Python\u6269\u5c55\u3002\u5b89\u88c5\u5b8c\u540e\uff0c\u6253\u5f00\u60a8\u8981\u8c03\u8bd5\u7684Python\u6587\u4ef6\uff0c\u6309\u4e0b\u201cF5\u201d\u6216\u70b9\u51fb\u4fa7\u8fb9\u680f\u7684\u8c03\u8bd5\u56fe\u6807\uff0c\u9009\u62e9\u201cPython\u201d\u4f5c\u4e3a\u73af\u5883\u3002\u63a5\u4e0b\u6765\uff0c\u60a8\u53ef\u4ee5\u8bbe\u7f6e\u65ad\u70b9\uff0c\u67e5\u770b\u53d8\u91cf\u503c\uff0c\u5e76\u9010\u884c\u6267\u884c\u4ee3\u7801\u3002\u914d\u7f6elaunch.json\u6587\u4ef6\u53ef\u4ee5\u8fdb\u4e00\u6b65\u81ea\u5b9a\u4e49\u8c03\u8bd5\u53c2\u6570\u3002<\/p>\n<p><strong>VSCode\u8c03\u8bd5Python\u65f6\u5e38\u89c1\u9519\u8bef\u6709\u54ea\u4e9b\uff1f<\/strong><br \/>\u5728\u8c03\u8bd5Python\u4ee3\u7801\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u5e38\u89c1\u9519\u8bef\uff0c\u4f8b\u5982\u201c\u65e0\u6cd5\u627e\u5230Python\u89e3\u91ca\u5668\u201d\u6216\u201c\u7f3a\u5c11\u6a21\u5757\u201d\u3002\u786e\u4fdd\u5728VSCode\u7684\u8bbe\u7f6e\u4e2d\u6b63\u786e\u6307\u5b9a\u4e86Python\u89e3\u91ca\u5668\u8def\u5f84\u3002\u6b64\u5916\uff0c\u786e\u4fdd\u6240\u9700\u7684\u5e93\u5df2\u5b89\u88c5\u5e76\u4e14\u80fd\u591f\u5728\u547d\u4ee4\u884c\u4e2d\u6b63\u5e38\u5bfc\u5165\u3002\u5982\u679c\u95ee\u9898\u4f9d\u7136\u5b58\u5728\uff0c\u53ef\u4ee5\u67e5\u770b\u8f93\u51fa\u7a97\u53e3\u548c\u8c03\u8bd5\u63a7\u5236\u53f0\u83b7\u53d6\u8be6\u7ec6\u9519\u8bef\u4fe1\u606f\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728VSCode\u4e2d\u4f7f\u7528\u8c03\u8bd5\u63a7\u5236\u53f0\uff1f<\/strong><br \/>\u8c03\u8bd5\u63a7\u5236\u53f0\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u5728\u8c03\u8bd5\u8fc7\u7a0b\u4e2d\u8bc4\u4f30\u8868\u8fbe\u5f0f\u548c\u67e5\u770b\u53d8\u91cf\u72b6\u6001\u3002\u5f53\u60a8\u5728\u8c03\u8bd5\u65f6\uff0c\u63a7\u5236\u53f0\u4f1a\u663e\u793a\u5728\u4e0b\u65b9\uff0c\u60a8\u53ef\u4ee5\u76f4\u63a5\u8f93\u5165Python\u4ee3\u7801\u6765\u6d4b\u8bd5\u53d8\u91cf\u6216\u51fd\u6570\u3002\u4f7f\u7528\u8c03\u8bd5\u63a7\u5236\u53f0\u53ef\u4ee5\u5e2e\u52a9\u60a8\u5feb\u901f\u53d1\u73b0\u95ee\u9898\u5e76\u9a8c\u8bc1\u60a8\u7684\u4ee3\u7801\u903b\u8f91\uff0c\u800c\u65e0\u9700\u53cd\u590d\u4fee\u6539\u6e90\u4ee3\u7801\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Visual Studio Code\uff08VS Code\uff09\u662f\u4e00\u6b3e\u5f3a\u5927\u4e14\u7075\u6d3b\u7684\u4ee3\u7801\u7f16\u8f91\u5668\uff0c\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u8c03\u8bd5Pyt [&hellip;]","protected":false},"author":3,"featured_media":1151978,"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\/1151972"}],"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=1151972"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1151972\/revisions"}],"predecessor-version":[{"id":1151982,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1151972\/revisions\/1151982"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1151978"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1151972"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1151972"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1151972"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}