vscode带命令行参数进行调试的方法
作者:思wu邪
文章介绍了如何在VSCode中使用命令行参数进行调试,并描述了如何通过修改`launch.json`文件来简化调试过程
vscode带命令行参数进行调试
1

2.输入代码
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: 当前文件",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
// "env": {"CUDA_VISIBLE_DEVICES":"0,1,2,3"},
"args": [
"--train --config=configs/lane_detection/resa/erfnet_tusimple.py"
]
}
]
}
上述程序带的命令行参数:--train --config=configs/lane_detection/resa/erfnet_tusimple.py
启动的方式就是:首先打开你要运行的文件,然后点击即可

2022-5-13 08:30:28 :对上述launch.json编写的方式现在换了个新的:
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
// python main_landet.py --train --config=configs/lane_detection/resa/erfnet_tusimple.py
"name": "Train_erfnet_tusimple",
"type": "python",
"request": "launch",
"program": "main_landet.py",
"args": [
"--train",
"--config=configs/lane_detection/resa/erfnet_tusimple.py"
],
"console": "internalConsole",
"justMyCode": true
},
{
// python main_landet.py --test --config=configs/lane_detection/resa/erfnet_tusimple.py
"name": "Test_erfnet_tusimple",
"type": "python",
"request": "launch",
"program": "main_landet.py",
"args": [
"--test",
"--config=configs/lane_detection/resa/erfnet_tusimple.py"
],
"console": "internalConsole",
"justMyCode": true
},
]
}
json文件里面指定了运行哪个文件,可以按F5直接运行,而不用再打开要运行的文件了。
到此这篇关于vscode带命令行参数进行调试的方法的文章就介绍到这了,更多相关vscode带命令行参数进行调试内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
