一、调出launch.json文件
- 点击运行
- 点击创建launch.json文件
- 点击 Python File
- 此时,在.vccode文件夹中新建了launch.json文件
二、修改launch.json文件,让vccode能读取相对路径
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: 当前文件",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"cwd": "${fileDirname}" //加上这一句,Visual Studio Code就可读取相对路径
}
]
}