【发布时间】:2011-10-24 06:33:21
【问题描述】:
我想在 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 打印会使 python 崩溃...
【问题讨论】:
-
是什么让你认为你首先在这里打印 utf8?
-
我刚刚更新了我的答案 - 这是在 Python 3.3 中添加的。
标签: python windows unicode utf-8 windows-xp