2017-09-25 91 views
0

我正在尝试调试这个非常简单的代码,但输入数字后它不会执行任何操作。我无法使用Python调试Visual Studio代码中的简单代码

import math 

pi = math.pi 

r = int(input('Enter number:')) 

circum = 2 * pi * r 
print(circum) 

但不包含input()简单和复杂的代码,我可以很容易调试。当我在Spyder中调试此代码时,它完美无瑕,但不在Visual Studio代码中。我真的需要帮助

PS。我已经配置launch.json

+0

在控制台输出,你看到了什么?没有? – Vladyslav

+0

我插入一个数字后,这段代码应该显示变量'circum'的结果。在Visual Studio代码中,它并没有显示任何内容,仍然继续调试。 –

+0

检查,也许你看到另一个窗口,检查输出'输出'标签int'TERMINAL'等输出 – Vladyslav

回答

0

我得到它的工作,当我切换到使用“集成终端/控制台”调试配置。

{ 
     "name": "Integrated Terminal/Console", 
     "type": "python", 
     "request": "launch", 
     "stopOnEntry": true, 
     "pythonPath": "${config:python.pythonPath}", 
     "program": "${file}", 
     "cwd": "", 
     "console": "integratedTerminal", 
     "env": {}, 
     "envFile": "${workspaceRoot}/.env", 
     "debugOptions": [ 
      "WaitOnAbnormalExit", 
      "WaitOnNormalExit" 
     ] 
    }, 

enter image description here

enter image description here

https://donjayamanne.github.io/pythonVSCodeDocs/docs/debugging_terminal-console-apps/#Option-1

+0

有一点要注意,我的Python版本是2.7。这应该仍然适用于3. +。常规的Python配置不接受用户输入,这就是为什么即使在调试控制台中程序也会冻结的原因。当我切换到“集成终端/控制台”时,控制台允许用户接受输入。 – Eric

+1

非常感谢 –

+0

不客气:-) – Eric

相关问题