首页 > 代码库 > UnicodeDecodeError: 'utf-8' codec can't decode byte 0xef in position 99: invalid continuation byte

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xef in position 99: invalid continuation byte

Traceback (most recent call last):
  File "/Users/c2apple/PycharmProjects/easyToPython/fileMethod.py", line 94, in <module>
    line=fp.readline()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/codecs.py", line 321, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: utf-8 codec cant decode byte 0xef in position 99: invalid continuation byte

出现这种情况是由于读取后进行转码出现错误,遇到了非法字符,解决的方法是检测读取的文件编码,再进行下一步转码形式处理

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xef in position 99: invalid continuation byte