我的VS代码调试文件夹是:C:\Users\EML\Python Code
我正在处理的文件在:C:\Users\EML\Python Code\Boggle中我有文件en-dict.txt,但我收到以下错误消息
with open("en-dict.txt", "r", encoding="utf8") as file:
FileNotFoundError: [Errno 2] No such file or directory: 'en-dict.txt'这是我在VS代码中的launch.json设置:
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"cwd": "${fileDirname}"
}我看过很多StackOverflow的答案,但没有一个对我有帮助。
发布于 2019-06-19 18:46:15
如果将启动设置为:
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"cwd": ""
}它将调用与其所在目录相同的python。
发布于 2019-06-20 04:51:39
尝试在VS代码中打开C:\Users\EML\Python Code\Boggle,而不是C:\Users\EML\Python Code,因为这将隐式地使工作目录成为您所期望的。否则,在启动调试器时,必须非常注意打开的文件,以确保正确设置了${fileDirname}。否则,您可以在launch.json中对工作目录进行硬编码。
https://stackoverflow.com/questions/56665710
复制相似问题