更新时间:2022-02-23 09:17:48
技巧这个工作在扩展的(Don Jayamanne的Python) wiki上页.您必须在 launch.json
文件的 "name": "Python"
部分中包含 "externalConsole": true
设置.
The trick to getting this to work is on the extension's(Don Jayamanne's Python) wiki page. You have to include "externalConsole": true
setting in your launch.json
file's "name": "Python"
section.
扩展的维基确认这在默认情况下不起作用:
The extension's wiki confirms that this does not work by default:
这允许从控制台/终端窗口捕获输入应用程序,这在标准 VSCode 调试器中是不可能的.
This allows for capturing of input from the console/terminal window applications, which isn't possible in the standard VSCode debugger.
以下是使其工作的步骤:
Here are the steps to getting this to work:
.vscode
目录中,您在 VS Code 中选择作为打开文件夹"的任何文件夹.pythonPath
参数添加到第一个配置块.这是让调试器工作所必需的.externalConsole
参数添加到同一块中.这是让调试器接受输入所需要的.调试时,会在 VS Code 之外打开一个单独的窗口,但在其他情况下运行良好.添加两个设置后,块应该看起来像这样.我不必更改 launch.json 文件的其余部分中的任何其他内容.
.vscode
directory in what ever folder you have selected as your "Open Folder" in VS Code.pythonPath
parameter to the first configuration block. This is needed to have the debugger work at all.externalConsole
parameter to the same block. This is what is needed to have the debugger accept input. When you debug, a separate window will open outside of VS Code but works well otherwise. After you add both settings, the block should look something like this. I did not have to change anything else in the rest of the launch.json file.
{
"name": "Python",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"program": "${file}",
"pythonPath": "C:/Users/igor/Documents/Tools/WinPython-32bit-3.4.3.7Slim/python-3.4.3/python.exe",
"externalConsole": true,
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
]
},