VScode中python断点调试

83 阅读1分钟

如题,设置非常简单但是非常实用。 首先在项目目录下新建.vscode/launch.json文件(如果有就不用重新创建了,直接添加内容即可),在其中加入如下内容:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python Debugger: main.py",
            "type": "debugpy",
            "request": "launch",
            "program": "main.py",
            "console": "integratedTerminal",
            "args": [
                "start"
            ]
        },
        // 如果有第二个调试文件往后加即可
    ]
}

image.png

添加完成之后,就可以在调试运行界面下运行自己需要执行的调试文件了

image.png

之后点击选择框前边的运行按钮即可,其会在断点处停下。