在 Python Tools for Visual Studio (PTVS) 中调试 python 代码时如何抑制控制台 window?

How do I suppress the console window when debugging python code in Python Tools for Visual Studio (PTVS)?

在 PTVS 中,程序的默认行为是打印到 Python 控制台 window 和 Visual Studio 调试输出 window。

意识到它无法接受用户输入,我该如何抑制 Python 控制台 window?

这比预期的更难弄清楚,但像往常一样,一旦你知道就很简单。

快速回答。
在解决方案资源管理器中,右键单击项目和 select 属性。在常规选项卡上,选中 Windows 应用程序旁边的框。

然后保存并关闭属性window。完成!


2012 年在 PTVS codeplex 网站上发布的问题讨论的其他详细信息。
Python shell appears in addition to output window of IDE

The typical way to hide the Python console window is to set the Windows Application property (in the project properties window), which will then run pythonw.exe instead of python.exe. This is only really an option if you don't provide any input while your program is running - the output window in VS is not a console and does not support typing into your program. Also, this option is per-project, so you'll have to set it for each project. (It also seems to not be working in our latest builds, so we'll fix that asap...)

The other option is to stop printing output in Visual Studio and only use the console window. If you are suffering performance issues, this is more likely to solve the problem. To do this, open Tools->Options->Python Tools->Advanced and deselect "Tee program output to Debug Output window". You will probably also want to select "Wait for input when process exits normally" while you are here. Now all output will go to the Python console (you can right-click the title bar and choose Properties to make it bigger), which will be faster.

使用 Python 交互式 Window(CTRL-ALT-F8 或调试菜单)。您将在 python 交互式 shell 上获得代码输出(您显然可以在其中进行交互)。 win 终端将不再出现。