我想在Windows XP上配置我的控制台以支持UTF8并让python检测并使用它。使用控制台在Windows XP上以UTF8格式打印python
到目前为止,我的尝试:
C:\Documents and Settings\Philippe>C:\Python25\python.exe
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> print u'é'
é
>>> import sys
>>> sys.stdout.encoding
'cp437'
>>> quit()
所以,在默认情况下,我在CP437和Python检测就好了。
C:\Documents and Settings\Philippe>chcp 65001
Active code page: 65001
C:\Documents and Settings\Philippe>python
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.stdout.encoding
'cp65001'
>>> print u'é'
C:\Documents and Settings\Philippe>
好像在UTF8印刷使得现在蟒蛇崩溃......
是什么让你觉得你打印UTF8这里摆在首位? –
我刚刚更新了我的答案 - 这是在Python 3.3中添加的。 –
另请参阅:http://stackoverflow.com/a/30505612/788700 – Adobe