Python.exe 在新的控制台窗口中打开 [英] Python.exe opens in a new console window

查看:37
本文介绍了Python.exe 在新的控制台窗口中打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经从我的 Windows 命令行运行 Python 脚本,并且所有打印都在同一个控制台中打印.现在我的机器(Windows 10)上发生了一些事情,当我从命令行启动 Python 脚本时(即打开命令提示符并运行 python <my_script.py>),Windows 会打开一个新的窗口(以 python.exe 的绝对路径为标题).此窗口在执行结束时自动关闭,因此我看不到输出.

I used to run Python scripts from my Windows command line, and all the prints were printed in the same console. Now something happened on my machine (Windows 10), and when I launch a Python script from the command line (i.e. open a Command Prompt and run python <my_script.py>), Windows opens a new window (titled with the absolute path of python.exe). This windows closes automatically at the end of the execution, so that I can't see the output.

如何在运行脚本的同一命令提示符窗口中返回打印输出?

How do I go back to printing output in the same command prompt window from which I run the script?

推荐答案

不确定这会有多大用处,但我遇到了同样的问题,找到了这个线程,并意识到当我省略 'python 时新的控制台窗口正在打开' 来自命令.

Not sure how useful this will be but I had this same problem, found this thread, and realized that the new console window was opening up when I omitted 'python' from the command.

>python myscript.py

在我输入命令的终端中显示输出,但是

shows the output right in the terminal where I typed the command, but

>myscript.py

打开新的控制台窗口并在脚本运行后立即关闭它.

opens the new console window and closes it immediately after the script runs.

这篇关于Python.exe 在新的控制台窗口中打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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