pyinstaller冲洗输入 [英] Pyinstaller flush input
本文介绍了pyinstaller冲洗输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个python程序,可以在Pycharm环境中正常工作。
I've a python program which works fine within the Pycharm environment.
我尝试使用Pyinstalle将其编译为一个文件可执行文件。
可以正常工作,但是直到选择它,我看不到输出。
我实际上是使用ctrl + A偶然发现的。
I tried compiling it with Pyinstalle to a onefile executable. It works fine, but I see no output till I select it. I actually casually discovered this using ctrl+A.
我尝试添加flush = True打印,但没有结果。
I tried adding flush=True to print, but with no results.
程序以简单的打印开始,甚至第一个都不会显示。
The program starts with a simple print and even that first one won't show up.
有什么想法吗?
编辑:这似乎也停止了执行,但我不确定。
It also seems like that this "buffering" stops execution, but I'm not completely sure of that.
推荐答案
使用
sys.stdout.flush()
而不是
print("", flush=True)
为我解决了这个问题。
这篇关于pyinstaller冲洗输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文