<p>在Py3K中,至少来自Python 3.2-<code>subprocess.Popen</code>和<code>sys.argv</code>的字符串与Windows上的(默认unicode)字符串一致。<code>CreateProcessW</code>和<code>GetCommandLineW</code>使用明显。</p>
<p>在Python中-到v2.7.2版本至少-<code>subprocess.Popen</code>有Unicode参数的错误。它坚持<code>CreateProcessA</code>(而<code>os.*</code>与Unicode一致)。而且<code>shlex.split</code>会产生额外的废话。</p>
<p>Pywin32的<code>win32process.CreateProcess</code>也不会自动切换到W版本,也没有<code>win32process.CreateProcessW</code>。与<code>GetCommandLine</code>相同。
因此需要使用<code>ctypes.windll.kernel32.CreateProcessW...</code>。
关于这个问题,可能应该修复子流程模块。</p>
<p>在Unicode操作系统上,使用私有应用程序的UTF8仍然很笨拙。对于像Linux这样的8位“Latin1”字符串操作系统,这样的技巧可能是合法的。</p>
<p><strong>更新</strong>vaab为Python 2.7创建了<code>Popen</code>的修补版本,该版本修复了该问题。<br/>
见<a href="https://gist.github.com/vaab/2ad7051fc193167f15f85ef573e54eb9" rel="nofollow noreferrer">https://gist.github.com/vaab/2ad7051fc193167f15f85ef573e54eb9</a><br/>
有解释的博客文章:<a href="http://vaab.blog.kal.fr/2017/03/16/fixing-windows-python-2-7-unicode-issue-with-subprocesss-popen/" rel="nofollow noreferrer">http://vaab.blog.kal.fr/2017/03/16/fixing-windows-python-2-7-unicode-issue-with-subprocesss-popen/</a></p>