【问题标题】:How to start python in "-X dev" mode when debugging / running from terminal?从终端调试/运行时如何以“-X dev”模式启动python?
【发布时间】:2025-12-02 03:05:02
【问题描述】:

python3支持-X dev启动模式。

此功能对于代码“环境感知”和执行功能变得非常有用。

例如。 asyncio 模块的调试打印https://docs.python.org/3/library/asyncio-dev.html#debug-mode-of-asyncio

如何配置 vscode 以使用此标志启动 python?

【问题讨论】:

  • 你解决过这个问题吗?如果是这样,我很想知道答案

标签: python debugging visual-studio-code


【解决方案1】:

vscode 现在支持launch.json 中的pythonArgs,但请注意,它需要['-X', 'dev'] 的格式:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "pythonArgs": ["-X", "dev"],
        },
    ]
}

【讨论】:

    最近更新 更多