擅长:python、mysql、java
<p>一个可能的解决方案,看起来像是运行在同一个shell中:</p>
<pre><code>subprocess.Popen('echo start;echo mid;echo end', shell=True)
</code></pre>
<p>注意-如果将命令作为字符串传递,那么shell必须为True
注意-这仅适用于linux,您可能需要在windows上找到类似的解决方法。</p>
<p>希望能有所帮助。</p>
<p>来自python文档-</p>
<blockquote>
<p>On Unix with shell=True, the shell defaults to /bin/sh. If args is a
string, the string specifies the command to execute through the shell.
This means that the string must be formatted exactly as it would be
when typed at the shell prompt.</p>
</blockquote>