我有以下代码
commands = [["openstack", "volume", "delete", i], ["openstack", "volume", "snapshot", "delete", i]]
programs = [subprocess.Popen(i) for i in commands]
我知道我可以使用
获取错误和输出p = subprocess.Popen(command, stdout=subprocess.PIPE)
out, err = p.communicate()
我只是错过了在programs
中使用相同内容的想法。我需要知道命令是否导致错误或者获得输出。有什么指针吗?