问题
In this two-line python code:
string = input("What's your name? ")
if string != '': print('Hello, ' + string + '!')
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
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.
回答1:
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.
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.
来源:https://stackoverflow.com/questions/63442844/vscode-cannot-read-user-input-while-debugging-a-python-code-in-integratedtermina