重现错误,将 cmd 编码设置为1252就会出现和楼主一样的错误,改回936就可以正常输出中文:
D:\>chcp 1252
Active code page: 1252
D:\>c:\Python33\python.exe
t.pyTraceback (most recent call last):
File "
t.py", line 4, in <module>
print(a)
File "c:\Python33\lib\encodings\
cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-2: cha
racter maps to <undefined>