UnicodeDecodeError: 'charmap' codec can't decode byte X in position Y: character maps to

前端 未结 9 1667
情歌与酒
情歌与酒 2020-11-22 00:43

I\'m trying to get a Python 3 program to do some manipulations with a text file filled with information. However, when trying to read the file I get the following error:

9条回答
  •  暖寄归人
    2020-11-22 01:01

    Stop wasting your time, just add the following encoding="cp437" and errors='ignore' to your code in both read and write:

    open('filename.csv', encoding="cp437", errors='ignore')
    open(file_name, 'w', newline='', encoding="cp437", errors='ignore')
    

    Godspeed

提交回复
热议问题