我使用此命令获取输出:
command_fping = ["fping", 'wikipedia.org','-c 3']
p = subprocess.check_output(command_fping)
print("P is,",p)
现在终端上显示的是:
^{pr2}$
我需要访问第一条输出线。在
"wikipedia.org : xmt/rcv/%loss = 3/3/0%, min/avg/max = 343/347/351" <-- This line!
我该怎么做?在
Tags:
尝试将
stderr=subprocess.STDOUT
作为参数添加到check_output()
。如果您的命令除了stdout还写入stderr,则需要这样做。如果只需要stderr输出,甚至可以尝试将stdout重定向到nowhere。在相关问题 更多 >
编程相关推荐