Constantly print Subprocess output while process is running

后端 未结 13 821
庸人自扰
庸人自扰 2020-11-22 06:51

To launch programs from my Python-scripts, I\'m using the following method:

def execute(command):
    process = subprocess.Popen(command, shell=True, stdout=s         


        
13条回答
  •  情话喂你
    2020-11-22 07:23

    For anyone trying the answers to this question to get the stdout from a Python script note that Python buffers its stdout, and therefore it may take a while to see the stdout.

    This can be rectified by adding the following after each stdout write in the target script:

    sys.stdout.flush()
    

提交回复
热议问题