阅读背景:

将stdout从subprocess.Popen保存到文件,再将更多内容写入文件

来源:互联网 

I'm writing a python script that uses subprocess.Popen to execute two programs (from compiled C code) which each produce stdout. The script gets that output and saves it to a file. Because the output is sometimes large enough to overwhelm subprocess.PIPE, causing the script to hang, I send the stdout directly to the log file. I want to have my script write something to the beginning and end of the file, and between the two subprocess.Popen calls. However, when I look at my log file, anything I wrote to the log file from the script is all together at the top of the file, followed by all the executable stdout. How can I interleave my added text to the file?I'm writing a python script that uses subproces




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: