我的python脚本使用子进程来调用另一个脚本,这会产生非常慢的输出(逐行).我希望在整个过程结束时将输出逐行写入文件并将整个输出写为字符串.以下代码在"脚本"结束时将输出写入"文件".
args = ("script") file = open('output.txt', 'w') subprocess.Popen(args,stdout=file)
它甚至可能吗?谢克斯,克里斯
python subprocess
python ×1
subprocess ×1