gpt4 book ai didi

python - "Python: Current File (Integrated Terminal)"-Visual Studio 代码

转载 作者:行者123 更新时间:2023-12-01 08:01:04 25 4
gpt4 key购买 nike

我在调试 python 文件时打开 VS code 集成终端时遇到问题。VS 代码显示:'${file} 无法解析。请打开编辑器。'

我正在使用:https://www.youtube.com/watch?v=dNFgRUD2w68

我的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 (Integrated Terminal)",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"stopOnEntry": false
}```
]
}

最佳答案

在 Visual Studio Code 中,您需要在运行和调试 Python 脚本之前打开工作区文件夹。如果不是,VSCode 将无法解析例如 ${file}${workspaceFolder}

打开工作区文件夹后,底部状态栏的颜色会发生变化(取决于您选择的主题),表明您现在位于工作区中。然后只需单击左侧栏上的调试符号和左上角的齿轮符号(您可以单击开始调试)。

这将自动在根目录(您的工作区)内创建一个 .vscode 文件夹,并在其中添加一个 launch.json 。现在${file}可以解析了。

这里是 predefined variables 的列表受 VScode 支持,这对于配置调试选项非常有用。

关于python - "Python: Current File (Integrated Terminal)"-Visual Studio 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55728241/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com