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 can't decode byte 0xef in position 99: invalid continuation byte

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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM