аватар question@mail.ru · 01.01.1970 03:00

Coding error in Python: Readline () when reading the UTF-8 of the file swings: 'charmap' codec can't decode byte

Trying to read the port file from Iana. It is saved in the encoding UTF-8 W/O BOM. But on one of the lines the function of readline () swears in this way

'Charmap' Codec Canat Decode 0x98 in Position 7938: Character Maps to & lt; "Undefined" & gt;

The line in the file looks as follows:

# Jim Harlan & lt; "" Jimh & amp; infowest.com "& gt;

What crutch to come up with for this? Or is there a direct solution to the solution?

upd

for the crutch in the form of removing this line will go (and for some reason it is one), but only during the debugging, because then suddenly, the partners will tear my hair on my head. I will also post the code that I use for this operation:

   try :  file = "" "> open  (Path, Path, PATH.  'r' )   when   true :  line = file.readline ()   if  ( not  line):   break    print  (line)   finally :  FILE.CLOSE ()   

Latest

Similar