你如何在visual studio中运行python程序

时间:2016-06-26 11:16:23

标签: python json

每当我点击 f5键运行程序时,会打开一个名为launch.json的新文件,但我不知道该怎么做。有没有人知道要做的帽子,这与我如何为visual studio安装python不同。 这就是launch.json的样子。

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python",
            "type": "python",
            "request": "launch",
            "stopOnEntry": true,
            "program": "${file}",
            "debugOptions": [
                "WaitOnAbnormalExit",
                "WaitOnNormalExit",
                "RedirectOutput"
            ]
        },
        {
            "name": "Python Console App",
            "type": "python",
            "request": "launch",
            "stopOnEntry": true,
            "program": "${file}",
            "externalConsole": true,
            "debugOptions": [
                "WaitOnAbnormalExit",
                "WaitOnNormalExit"
            ]
        },
        {
            "name": "Django",
            "type": "python",
            "request": "launch",
            "stopOnEntry": true,
            "program": "${workspaceRoot}/manage.py",
            "args": [
                "runserver",
                "--noreload"
            ],
            "debugOptions": [
                "WaitOnAbnormalExit",
                "WaitOnNormalExit",
                "RedirectOutput",
                "DjangoDebugging"
            ]
        },
        {
            "name": "Watson",
            "type": "python",
            "request": "launch",
            "stopOnEntry": true,
            "program": "${workspaceRoot}/console.py",
            "args": [
                "dev",
                "runserver",
                "--noreload=True"
            ],
            "debugOptions": [
                "WaitOnAbnormalExit",
                "WaitOnNormalExit",
                "RedirectOutput"
            ]
        }
    ]
}

提前致谢!

1 个答案:

答案 0 :(得分:0)

我猜你的意思是VS Code。如果是这种情况,这是一个自动生成的文件,您可以在其中配置按F5时会发生的情况。如果您按原样保存该文件,然后切换回您的main.py或您要调试的任何python文件,再次按F5,您将开始使用第一个可执行行上的断点进行调试。