python读取文件出现字符编码错误

 

UnicodeDecodeError: 'gbk' codec can't decode byte 0xbf in position 2: illegal multibyte sequence

 

 

在某种情况下忽略字符错误

file = open(path, encoding='gb18030', errors='ignore')

 

posted @ 2021-01-22 10:32  leechg  阅读(171)  评论(0编辑  收藏  举报