擅长:python、mysql、java
<p>Lior Dagan的代码几乎是正确的/功能性的:这种方法中的错误是对<code>subprocess.Popen</code>的调用中缺少<code>shell=True</code>{<cd2>}。任何实际考虑这种方法的人都应该知道<code>subprocess</code>文档警告:</p>
<pre><code>Invoking the system shell with shell=True can be a security hazard if combined with untrusted input.
</code></pre>
<p>通常,应该首选F0RR和ghostdog74的解决方案,因为它们更健壮、更安全</p>