【python】报错UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte in position : illegal multibyte

python读文件时报错:

Traceback (most recent call last):
  File "xxx.py", line 3, in <module>
    for line in input_file:
UnicodeDecodeError: 'gbk' codec can't decode byte 0x91 in position 5458: illegal multibyte sequence

解决方法(不保证内容完整读取):
加入errors='ignore'
例如:

with open('xxxx.csv', 'r', errors='ignore') as input_file:
with open('xxxx.csv', 'r', encoding='utf-8', errors='ignore') as f:

你可能感兴趣的:(Python,python)