我试图将以下子进程调用的输出放入dict或列表中。然后,我将从那里提取一些数据。
arg_list = []
action ="QuotaInfo"
arg_list.append(upnp_path)
arg_list.append(' --action=')
arg_list.append(action)
arg_list.append(' --ip=')
arg_list.append('10.10.8.89')
# x = Popen(arg_list, shell=True)
output = list()
y = subprocess.call(["python", arg_list])
输出
***************Retrieving the QUOTA info for : 10.10.8.89 ***************
INFO::root:Trying main server 10.10.8.40:9000::224
DEBUG::root:Cookies: 'TWISTED_SESSION=988fedac2b7f62cc280c6865f74d9600'::107
containerId : 3
title : pvr
quotaInfoName : user
quotaInfoUsedsize : 17767158
containerRestricted : 0
quotaInfoMaxsize : 239221162
class : object.container
containerParentid : 0
INFO::root:Trying main server 10.10.8.40:9000::224
DEBUG::root:Cookies: 'TWISTED_SESSION=988fedac2b7f62cc280c6865f74d9600'::107
我怎么能做到这一点?感谢
答案 0 :(得分:0)
我自己找到答案。
from subprocess import Popen, PIPE, STDOUT
p = Popen(command, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT)
output = p.stdout.read()
print output