I'm trying to read the ports file from IANA. It is stored in UTF-8 w / o BOM. But on one of the lines, the readline() function swears like this
'charmap' codec can't decode byte 0x98 in position 7938: character maps to <"undefined">
The line in the file looks like this:
# Jim Harlan <"jimh & infowest.com">
What a crutch to come up with for this? Or is there a direct solution?
UPD
For a crutch in the form of deleting this line will go (and she, for some reason, is one here), but only for the time of debugging, because then suddenly that partners will tear the hair on my head. Also lay out the code that I use for this operation:
try: file = open(path, 'r') while True: line = file.readline() if(not line): break print(line) finally: file.close()