针对不同文件的VSCode启动文件调试配置

4

我正在使用VSCode调试Python文件。我有两个脚本,称为 a.pyb.py。这两个文件使用不同的参数。我想配置 launch.json 以使当我运行 a.py 时,它应该输入对应的参数,其他文件也是如此。然而,在启动文件中没有 if 语句。如果我编写两个配置,它们只会按顺序运行。我的 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": "${WorkspaceFolder}/src/data_processing/main.py",
        "console": "integratedTerminal",
        "env": {
            "PYTHONPATH": "${workspaceRoot}"
        },
        "args": [
            "/home/gokberk/Desktop/filtered_data",
            "--gdc",
            "gdc-client",
            "--no-download",
            "--manifest",
            "/home/gokberk/Desktop/filtered_data/gdc_manifest.2021-05-26.txt",
            "--source-slides-folder",
            "/home/gokberk/Desktop/filtered_data"
        ]
    },
    {
        "name": "Python: Current File",
        "type": "python",
        "request": "launch",
        "program": "${WorkspaceFolder}/src/training.py",
        "console": "integratedTerminal",
        "env": {
            "PYTHONPATH": "${workspaceRoot}"
        },
        "args": [
            "--input-data-folder",
            "/home/gokberk/Desktop/filtered_data",
            "--alpha",
            "0.2",
            "--beta",
            "0.2",
            "--max-bag-size",
            "50",
            "--underlying-model-type",
            "resnet18",
            "--pretrained",
            "--no-download",
            "--source-slides-folder",
            "/home/gokberk/Desktop/filtered_data"
        ]
    }
]

}


两个配置都有相同的名称,可能会引发问题,请将其中一个的名称更改为其他名称。"name": "Python: Current File" => "name": "Python: Current File1" - Amir
1个回答

2

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接