Python 如何为VS代码设置lauch.json,以便我可以使用当前工作目录中的其他文件夹/文件?
我正在尝试编写python代码,该代码需要读取同一当前工作目录中的文件。我刚开始使用VS代码,所以我不知道如何设置它,使用下面的方法设置Python 如何为VS代码设置lauch.json,以便我可以使用当前工作目录中的其他文件夹/文件?,python,visual-studio-code,Python,Visual Studio Code,我正在尝试编写python代码,该代码需要读取同一当前工作目录中的文件。我刚开始使用VS代码,所以我不知道如何设置它,使用下面的方法设置launch.json,但它仍然不读取同一cwd中的其他文件。帮助:'v launch.json { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For mo
launch.json
,但它仍然不读取同一cwd中的其他文件。帮助:'v
launch.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”的默认设置是“${workspaceFolder}”。在VSCode中,相对路径取决于设置参数“cwd”,除非使用绝对路径。它不关心python文件的相对路径,只关心“cwd”的相对路径