【发布时间】:2017-10-19 13:53:34
【问题描述】:
with open('WarningErr.txt', 'w') as err:
subprocess.call(cmd, stderr=err)
with open('WarningOut.txt', 'w') as out:
return_code = subprocess.call(cmd, stdout=out)
现在,我将错误和输出都写在“.txt 和 stdout”中。
但是太慢了。我写在一个,然后在另一个。 我必须能够同时写两者。
复制一点 Bash 中的 tee 行为。
【问题讨论】:
-
您在通过
subprocess调用的命令中不包括tee吗? -
谢谢,但它与子进程调用 @Rightleg 配合得很好
标签: python subprocess stdout