打开vscode,点击左侧运行与调试,点击添加配置,选择python。会创建launch.json文件,还会创建.vscode文件夹。
launch.json内容:
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: 当前文件",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal"
}
]
}
在.vscode文件夹创建文件settings.json,输入如下内容:
{
"python.defaultInterpreterPath":"C:\\pythoncode\\webtest\\env\\Scripts\\python.exe",
"jupyter.debugJustMycode": true
}
第一行,引号内的路径是你自己的虚拟环境路径。