擅长:python、mysql、java
<p>除了lvc的答案之外,您还应该考虑使用<a href="https://docs.python.org/library/subprocess.html#subprocess.Popen.communicate" rel="nofollow">Popen.communicate()</a>。比如说</p>
<pre><code>import subprocess
string="file.py"
process=subprocess.Popen(string,stdin=subprocess.PIPE,stdout=subprocess.PIPE)
res=process.communicate("3 5")
print res[0]
</code></pre>
<p>这样你就不用睡觉了命令.it'将等待进程终止并返回元组(stdoutdata,stderdata)。你知道吗</p>