‘gb18030’ codec can’t decode byte 0x80 in position 10: incomplete multibyte sequence
出现这种报错的问题原因是:我们要解码的数据不符合我们期望的类型,所以有时候我们知道数据的编码格式,但是其中有一些其他格式的数据,这样我们就要将其他的格式数据进行忽略,否则解码会报错,程序运行不下去,在decode 中添加’ignore’参数即可
data_str = **
data.decode(‘gb18030’,’ignore’).encode(‘utf8’)
读取文件的时候也可以使用ignore
file = open(path, encoding=’gb18030’, errors=’ignore’)