餘米試圖從日誌文件中的行,使用代碼:的UnicodeDecodeError,UTF-8無效延續字節
with open('fichier.01') as f:
content = f.readlines()
print (content)
但它總是讓錯誤陳述
Traceback (most recent call last):
File "./parsepy", line 4, in <module>
content = f.readlines()
File "/usr/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 0xe9 in position 2213: invalid continuation byte
我怎麼能修理它 ??
你的文件是如何編碼的? – gonczor
如果你指出字節的內容,比如說2212到2219,它可能會有所幫助。 – greybeard