Python: UnicodeDecodeError: 'ascii' codec can't decode byte 0xef in position 0: ordinal not in range(128)

后端 未结 4 843
名媛妹妹
名媛妹妹 2021-01-07 02:27

I\'m currently have an issue with my python 3 code.

 replace_line(\'Products.txt\', line, tenminus_str)

Is the line I\'m trying to turn in

4条回答
  •  庸人自扰
    2021-01-07 03:04

    Try adding encoding='utf8' if you are reading a file

    with open("../file_path", encoding='utf8'):
             # your code
    

提交回复
热议问题