问题:读文件出现编码错误
UnicodeDecodeError: ‘gbk’ codec can’t decode byte 0xbf in position 2: illegal multibyte sequence
方法:
指定编码格式,忽略错误
open('a.txt',encoding='uft-8')
或
file = open('a.txt', encoding='gbk')
或
file = open('a.txt', encoding='gb18030')
或
file = open('a.txt', encoding='gb18030', errors='ignore')