gpt4 book ai didi

python - 如何在 VSCode Python 扩展中指定启动文件

转载 作者:行者123 更新时间:2023-12-03 16:51:31 24 4
gpt4 key购买 nike

在 Visual Studio 的 Python Tools for Visual Studio(url)当你有一个 Python 项目文件时,会有一个 Startup File 的概念。 .

Each Python project has one assigned start-up file, shown in boldface in Solution Explorer. The startup file is the file that's run when you start debugging (F5 or Debug > Start Debugging) or when you run your project in the Interactive window (Shift+Alt+F5 or Debug > Execute Project in Python Interactive). To change it, right-click the new file and select Set as Startup File. Solution Explorer showing Startup File


VSCode 中的等价物是什么?的 Python 扩展?如何定位我目录中的特定文件以使用从我的 launch.json 中选择的当前调试设置运行文件

最佳答案

原来是 program属性。

program - executable or file to run when launching the debuggerhttps://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes


举个例子...
{
"name": "python launch foo",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/d1/d2/foo.py",
"cwd": "${workspaceFolder}",
"args": [ "${env:USERNAME}", "--optionX", "x1000" ]
"console": "integratedTerminal"
}
以前我只是用默认的 file 复制启动配置变量,它总是只运行工作区中打开的任何事件文件。
{
"name": "Python: Current File",
"type": "python",
"request": "launch",
"program": "${file}",
"cwd": "${workspaceFolder}",
}

关于python - 如何在 VSCode Python 扩展中指定启动文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54430216/

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