" ENV"参数“popen”不会在Windows上接受Unicode - minorUnicode错误 [英] "env" parameter to "popen" won't accept Unicode on Windows - minorUnicode bug

查看:65
本文介绍了" ENV"参数“popen”不会在Windows上接受Unicode - minorUnicode错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过了一个关于env的词典。变量到Popen用Unicode字符串

用于字典值。


得到:


文件D: \ Python24 \ lib \subprocess.py",第706行,在_execute_child中

TypeError:环境只能包含字符串


事实证明, env中的字符串参数必须是ASCII,

不是Unicode,即使Windows在CreateProcess中完全支持Unicode。


John Nagle

I passed a dict for the "env" variable to Popen with Unicode strings
for the dictionary values.

Got:

File "D:\Python24\lib\subprocess.py", line 706, in _execute_child
TypeError: environment can only contain strings

It turns out that the strings in the "env" parameter have to be ASCII,
not Unicode, even though Windows fully supports Unicode in CreateProcess.

John Nagle

推荐答案

John Nagle写道:
John Nagle wrote:

事实证明,env中的字符串参数必须是

ASCII,而不是Unicode,即使Windows在
CreateProcess中完全支持Unicode。
It turns out that the strings in the "env" parameter have to be
ASCII, not Unicode, even though Windows fully supports Unicode in
CreateProcess.



您确定它支持Unicode,而不是UTF8或UTF16吗?可能使用

之类的东西,比如你的thestring.encode(" utf16")会有所帮助。


问候,

Bj ?
-

BOFH借口#31:


蜂窝电话干扰

Are you sure it supports Unicode, not UTF8 or UTF16? Probably using
something like u"thestring".encode("utf16") will help.

Regards,
Bj?rn

--
BOFH excuse #31:

cellular telephone interference


1月14日下午6:26,Bjoern Schliessmann< usenet-

mail-0306.20.chr0n ... @ spamgourmet.comwrote:
On Jan 14, 6:26 pm, Bjoern Schliessmann <usenet-
mail-0306.20.chr0n...@spamgourmet.comwrote:

John Nagle写道:
John Nagle wrote:

事实证明,env中的字符串是参数必须是

ASCII,而不是Unicode,即使Windows在
CreateProcess中完全支持Unicode。
It turns out that the strings in the "env" parameter have to be
ASCII, not Unicode, even though Windows fully supports Unicode in
CreateProcess.



你确定它支持Unicode,而不是UTF8或UTF16吗?可能使用

之类的东西,比如你的thestring.encode(" utf16")会有所帮助。


Are you sure it supports Unicode, not UTF8 or UTF16? Probably using
something like u"thestring".encode("utf16") will help.



否则:bugs.python.org

Otherwise: bugs.python.org


>

问候,


Bj?


-

BOFH借口#31:

蜂窝电话干扰
>
Regards,

Bj?rn

--
BOFH excuse #31:

cellular telephone interference


1月14日下午6:26,John Nagle< na ... @ animats.comwrote:
On Jan 14, 6:26 pm, John Nagle <na...@animats.comwrote:

我通过了一个关于env的字典。变量到Popen用Unicode字符串

用于字典值。


得到:


文件D: \ Python24 \ lib \subprocess.py",第706行,在_execute_child中

TypeError:环境只能包含字符串


事实证明, env中的字符串参数必须是ASCII,

不是Unicode,即使Windows在CreateProcess中完全支持Unicode。
I passed a dict for the "env" variable to Popen with Unicode strings
for the dictionary values.

Got:

File "D:\Python24\lib\subprocess.py", line 706, in _execute_child
TypeError: environment can only contain strings

It turns out that the strings in the "env" parameter have to be ASCII,
not Unicode, even though Windows fully supports Unicode in CreateProcess.


>

John Nagle
>
John Nagle


这篇关于&QUOT; ENV&QUOT;参数“popen”不会在Windows上接受Unicode - minorUnicode错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆