VS Code调试Python

VS Code调试Python

配置调试

  1. 安装Python扩展
  2. 点击调试图标 → 创建launch.json
  3. 配置调试器

launch.json

1
2
3
4
5
6
7
8
9
10
11
12
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}

调试技巧

  • 断点:在行号左侧点击
  • 调试控制台:查看变量
  • 条件断点:右键设置条件

总结

VS Code是Python开发的利器。