Run file 模式
a. python安装目录/lib/site-packages文件夹下,新建任意名字.pth文件
b. 文件内容: “你项目的绝对路径” 如:C:/workspace/demo
c. Vscode 工作区设置Terminal: Execute In File Dir 勾选
debug模式下
- 此方法仅在debug模式下生效
a. 设置launch.json,如果没有按下图创建
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: 当前文件",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"env": {"PYTHONPATH":"${workspaceFolder};${env:PYTHONPATH}"}
}
]
}