我想在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