While reading file on Python, I faced the error that said UnicodeDecodeError. What can I do to resolve this error? -
this 1 of own project. later benefits other people in game playing (assaultcube).
its purpose break down log file , make more easier read users.
i kept getting issue. know how fix this?
currently, not planning write/create file. wants error fixed.
the line triggered error actual blank line. ( stopped on line 66346 )
this relevant part of script looks like:
log = open('/users/owner/desktop/exodus logs/dirtylogs/serverlog_20130430_00.15.21.txt', 'r') line in log:
and exception is:
traceback (most recent call last): file "c:\users\owner\desktop\exodus logs\log file translater.py", line 159, in <module> main() file "c:\users\owner\desktop\exodus logs\log file translater.py", line 7, in main line in log: file "c:\python32\lib\encodings\cp1252.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0] unicodedecodeerror: 'charmap' codec can't decode byte 0x81 in position 3074: character maps <undefined>
try:
enc='utf-8' log = open('/users/owner/desktop/exodus logs/dirtylogs/serverlog_20130430_00.15.21.txt', 'r', encoding=enc)
if won't work try:
enc='utf-16' log = open('/users/owner/desktop/exodus logs/dirtylogs/serverlog_20130430_00.15.21.txt', 'r', encoding=enc)
you try with
enc='iso-8859-15'
also try:
enc = 'cp437'
wich old has "ü" @ 0x81 wich fit string "üßer" wich found on homepage of assault cube.
if codings wrong try contact of guys developing assault cube or mentioned in comment: have @ https://pypi.python.org/pypi/chardet
Comments
Post a Comment