问题
I've a python program which works fine within the Pycharm environment.
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.
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.
Any ideas?
EDIT: It also seems like that this "buffering" stops execution, but I'm not completely sure of that.
回答1:
Using
sys.stdout.flush()
Instead of
print("", flush=True)
solved the problem for me.
来源:https://stackoverflow.com/questions/50563758/pyinstaller-flush-input