当args参数作为序列给出时,我遇到了subprocess.Popen的问题.
例如:
import subprocess
maildir = "/home/support/Maildir"
Run Code Online (Sandbox Code Playgroud)
这工作(它打印正确的/ home/support/Maildir目录大小):
size = subprocess.Popen(["du -s -b " + maildir], shell=True,
stdout=subprocess.PIPE).communicate()[0].split()[0]
print size
Run Code Online (Sandbox Code Playgroud)
但是,这不起作用(尝试):
size = subprocess.Popen(["du", "-s -b", maildir], shell=True,
stdout=subprocess.PIPE).communicate()[0].split()[0]
print size
Run Code Online (Sandbox Code Playgroud)
怎么了?