Cannot redirect Pyinstaller single executable output while running it in subprocess

后端 未结 1 1739
轮回少年
轮回少年 2021-01-28 06:31

I\'ve been struggling with this for quite a while. I\'ve managed to write a code that can capture STDOUT of .py files, however when I run the exact same code with e

1条回答
  •  孤独总比滥情好
    2021-01-28 06:59

    It seems that when you compile the script you should set the flush of the print to True, so just change it to:

    import time
    
    if __name__ == "__main__":
        num = 0
        while True:
            num = num + 1
            print(num, flush=True)
            time.sleep(3)

    0 讨论(0)
提交回复
热议问题