参考:https://blog.csdn.net/yscoder/article/details/102556006
在vscode中如果使用相对路径打开文件时,直接在当前目录运行是没有问题的,但是使用调试模式时会提示找不到文件,是因为调试模式会自动进入调试模式配置文件的文件夹
在vscode中, 点击 调试->打开配置 ,在打开的launch.json文件增加 "cwd":"" ,
修改步骤如下


修改完的配置如下
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: 当前文件",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"stopOnEntry": true,
"cwd": ""
}
]
}