代码
# -- coding: utf-8 --
a='大小写'
print(a)
使用idel能正常输出
但是运行python -u d:\a.py 就报这个错误
报错
======================
Traceback (most recent call last):
File "D:\a.py", line 5, in <module>
print(a)
File "C:\Python30\lib\io.py", line 1491, in write
b = encoder.encode(s)
File "C:\Python30\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: character maps to <undefined>
是不是a.py保存的编码格式不是utf-8?