I am printing out the contents of a text file in python using wxpython in a gui window, but get the error message:
return _core_.TextEntryBase_WriteText(*args, **kwargs) File "C:\Python27\lib\encodings\cp1252.py", line 15, in decode return codecs.charmap_decode(input,errors,decoding_table) UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 60: character maps to <undefined> This is the line in the text file which trips it up:
<block count="55770" name="BASIC_LATIN"> !"%'(),-.0123456789:?ABCDEFGHIJKLMNOPQRSTUVWYZabcdefghijklmnopqrstuvwxyz</block> <block count="2" name="LATIN_1_SUPPLEMENT">éï</block> Any ideas on how I can get round this issue please?
open()in the adequate mode, likeinfile = open('test.txt', encoding='latin-1'). Ifinfilein your comment is a file object you already opened the file.