# Can't use shell=True if you want the pid of `du`, not the
# shell, so we have to do the redirection to file ourselves
proc = subprocess.Popen("/usr/bin/du folder", stdout=file("1.txt", "ab"))
print "PID:", proc.pid
print "Return code:", proc.wait()
&
将进程置于后台并输入作业号!=pid。获取进程的pid。我建议使用subprocess-a
Popen
实例具有可以直接访问的属性pid
。您需要使用
subprocess
模块。相关问题 更多 >
编程相关推荐