擅长:python、mysql、java
<p>通过传递带<code>env</code>关键字参数的映射,可以控制派生子流程中可用的环境变量。E、 g</p>
<pre><code>proc = subprocess.Popen(args, env={'PATH': '/some/path'})
</code></pre>
<p>或者从系统环境变量继承<code>PATH</code>,而不必从系统环境中删除其他内容:</p>
<pre><code>proc = subprocess.Popen(args, env={'PATH': os.getenv('PATH')})
</code></pre>
<p>不过,仅仅使用绝对路径可能更容易/更简单。</p>