擅长:python、mysql、java
<p><code>expandvars</code>故意扩展路径,引用python<a href="https://docs.python.org/2/library/os.path.html#os.path.expandvars" rel="nofollow noreferrer">docs</a>:</p>
<blockquote>
<p>Unlike a unix shell, Python does not do any automatic path expansions. Functions such as expanduser() and expandvars() can be invoked explicitly when an application desires shell-like path expansion. (See also the glob module.)</p>
</blockquote>
<p>如果要精确复制shell命令,可以使用<code>os.popen</code>:</p>
<pre><code>import os
output = os.popen("echo '$PATH'").read()
</code></pre>