如何为VS Code设置lauch.json,以便我可以使用当前工作目录中的其他文件夹/文件



我正在尝试编写python代码,该代码需要读取同一当前工作目录中的文件。我是一个使用VS代码的新手,所以我真的不知道如何按照以下方式设置launch.json,但它仍然无法读取同一cwd中的其他文件。帮助:'v

启动.json

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"cwd": "${workspaceFolder}"
}
]
}

${cwd}-任务运行者在启动时的当前工作目录

"cwd"的默认设置是"${workspaceFolder}";。在VSCode中,除非使用绝对路径,否则相对路径取决于设置参数"cwd"。它不关心python文件的相对路径,只关心"cwd"的相对路径。

最新更新