在IntegratedTerminal中调试python代码时,VSCode无法读取用户输入 [英] VSCode cannot read user input while debugging a python code in integratedTerminal

查看:176
本文介绍了在IntegratedTerminal中调试python代码时,VSCode无法读取用户输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在此两行python代码中:

In this two-line python code:

string = input("What's your name? ")

if string != '': print('Hello, ' + string + '!')

我运行时调试,它等待用户输入。输入名称后,终端(Python调试控制台)就在那里暂停,print()行永远不会执行。
请参见下面的屏幕截图

While I run debugging, it waits for user input. After typing a name, the Terminal (Python Debug Console) just halts there, the print() line never gets executed. See the screenshot below

launch.json文件在下面(默认情况下):

The launch.json file is below (as default):

{
    // 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": "${file}",
            "console": "integratedTerminal"
        }
    ]
}

如果我在不调试的情况下运行此代码,则一切

If I run this code without debugging, everything is OK.

注意:调试器之前可以正常工作。这个问题是最近才发生的。
非常感谢您的帮助或提示。

NOTE: The debugger works fine before. This problem just happened recently. Very much appreciate any helps or hints.

推荐答案

在我将python扩展回滚到以前的版本(v2020 .7.96456),那么问题就消失了,调试器可以前进到下一行代码,然后可以正常工作。

After I rolled back the python extension to its previous version (v2020.7.96456), then the problem is gone and the debugger can advance to next line of code and then works properly.

尽管我没有确凿的证据证明为什么要使用最新版本(v2020。 8.101144)导致调试器停止接受用户输入,至少回滚到以前的版本可能是一种临时补救措施,直到以后的修订版本解决了该问题为止。

Though I have no hard prove that why does the latest version (v2020.8.101144) cause the debugger stoping accepting user input, at least rolling back to a previous version can be a temporary remedy, until future revisions address this issue.

这篇关于在IntegratedTerminal中调试python代码时,VSCode无法读取用户输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆