擅长:python、mysql、java
<p>您需要使用<code>subprocess</code>模块。</p>
<pre><code># 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()
</code></pre>