[英]stdout of subprocess.Popen not working correctly
I am unable to save my output of subprocess.Popen
correctly.我无法正确保存
subprocess.Popen
输出。 I get this in the file I chose.我在我选择的文件中得到了这个。 The directory specified is correct, as just above I told it to erase text already existing in it, which worked.
指定的目录是正确的,就像上面我告诉它擦除其中已经存在的文本一样,这很有效。 Any solutions to this?
有什么解决办法吗?
Code is below代码如下
f = open("hunter_logs.txt", "w")
subp = subprocess.Popen(
'docker run -p 5001-5110:5001-5110/udp -v D:\Hunter\hunter\hunter-scenarios:/hunter-scenarios europe-west3-docker.pkg.dev/hunter-all/controller-repo/hunter_controller:latest -d /hunter-scenarios -s croatia -i OPFOR', stdout=f)
Probably the process is outputting some of its logs to stderr
and some to stdout
.可能该进程正在将其一些日志输出到
stderr
,将一些stdout
到stdout
。 Add stderr=f
as another argument to Popen()
in order to capture both streams to the same file.添加
stderr=f
作为Popen()
另一个参数,以便将两个流捕获到同一个文件中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.