'gbk' codec can't decode byte 0xae in position 3: illegal multibyte sequence在python里报这个错

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了'gbk' codec can't decode byte 0xae in position 3: illegal multibyte sequence在python里报这个错相关的知识,希望对你有一定的参考价值。

是什么意思啊?不是很明白,怎么解决啊?

参考技术A a.encode(encoding='utf-8').decode(encoding='gbk')UnicodeDecodeError: 'gbk' codec can't decode byte 0xad in position 2: illegal multibyte sequence ...

python读取文件时UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte

问题描述:
python读取log文件时,由于文件中有特殊字符,抛异常:UnicodeDecodeError: ‘gbk’ codec can’t decode byte
解决办法:读取文件时添加编码参数,使用utf-8编码,如下

file_data = open(file=inputfile, mode='r', encoding="utf-8")

以上是关于'gbk' codec can't decode byte 0xae in position 3: illegal multibyte sequence在python里报这个错的主要内容,如果未能解决你的问题,请参考以下文章

'gbk' codec can't encode character解决方法

python gbk 编码:'gbk'codec can't decode byte 0x81 in position 18

gbk codec can't encode character

gbk codec can't encode character

UnicodeEncodeError: 'gbk' codec can't encode character 'xbb' in position

Python UnicodeEncodeError: 'gbk' codec can't encode character 解决方法