" ENV"参数“popen”不会在Windows上接受Unicode

编程入门 行业动态 更新时间:2024-10-28 08:29:31
本文介绍了" 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 ... @ spamgourmetwrote: On Jan 14, 6:26 pm, Bjoern Schliessmann <usenet- mail-0306.20.chr0n...@spamgourmetwrote: 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

Otherwise: bugs.python

> 问候, Bj? - BOFH借口#31: 蜂窝电话干扰 > Regards, Bj?rn -- BOFH excuse #31: cellular telephone interference

1月14日下午6:26,John Nagle< na ... @ animatswrote: On Jan 14, 6:26 pm, John Nagle <na...@animatswrote: 我通过了一个关于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

本文发布于:2023-08-05 05:50:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1303068.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:会在   参数   ENV   QUOT   amp

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!