Python3 different behaviour between latin-1 and cp1252 when decoding unmapped characters
问题 I'm trying to read in Python3 a text file specifying encoding cp1252 which has unmapped characters (for instance byte 0x8d ). with open(inputfilename, mode='r', encoding='cp1252') as inputfile: print(inputfile.readlines()) I obviously get the following exception: Traceback (most recent call last): File "test.py", line 9, in <module> print(inputfile.readlines()) File "/usr/lib/python3.6/encodings/cp1252.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0]