2
我试图等待标准输出完成写入文件。有没有人有任何想法,我怎么能做到这一点?如何等待,直到标准输出完成写入文件
继承人的一段代码:
代码:选择所有
session = open("c:\\sessionID.txt", "w")
#Execute previous exe and output session to text file from the current directory
cmd = os.path.realpath(os.getcwd()) +"\\Program.exe"
cmd = [os.getcwd() + '\\AOSLaunch.exe']
Execute the cmd which executes the program.exe and the output is saved to the sessionID.txt file
process = subprocess.Popen(cmd, stdout=session)
session.close()
所以这里的问题是,它需要的Program.exe文件的时候启动并保存输出到标准输出能需要时间,有时sessionID.txt文件为空,因为它需要很长时间。在这里我想确保sessionID.txt已经被stdout写入。
任何帮助是极大的赞赏。 非常感谢 TMARZI