pyhton3环境,且开头加了
#coding=utf-8
情况一:
存在读取文件目录下文件类型错误,无法正常解析:
image.png image.png
File "/Users/tangkaisky/Desktop/Code/\u8bfb\u53d6\u6587\u4ef6\u5939\u4e0b\u6587\u4ef6\u66ff\u6362\u5b57\u7b26\u4e32.py", line 63, in ChangeFile
lines = open(filename,'r', encoding = "gbk").readlines()
UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 11: illegal multibyte sequence
情况二:
print()
print默认使用ascii,未能正确解析
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)
网友评论