# Time: 2020/05/31
#Author: Xiaohong
# 运行环境: OS: Windows 10
# Python: 3.7
# 功能: 读文件时,产生错误的解决方法
# 错误提示:
'utf-8' codec can't decode byte 0xb5 in position 0: invalid start byte
或:
'gbk' codec can't decode byte 0xfe in position 16172: illegal multibyte sequence
具体解释为:中文字符的Unicode编码0x0800-0xFFFF之间,(utf-8包含了部分汉字)。当你试图将该“中文字符”转成U码的utf-8时超出了其范筹。而GBK 规范收录了 ISO 10646.1 中的全部 CJK 汉字和符号,并有所补充,
fr_xyj=open('E:\\00000\\xyj.txt','r',encoding='gbk')
或:
fr_xyj=open('E:\\00000\\xyj.txt','r',encoding='GB18030')
或:
fr_xyj=open('E:\\00000\\xyj.txt','r',encoding='utf-8', errors='ignore')
https://www.crifan.com/files/doc/docbook/char_encoding/release/html/char_encoding.html