Python utf-8 encoding error


Hello everyone, I'm new to Python programming, I'm creating a program that reads information from a text and transcribes elsewhere.

Apparently the text was working normally on the computer, I uploaded all this information in github , when I generated this file on a new computer the following error occurred:


'utf-8' codec can not decode byte 0xea in position 1: invalid continuation byte.

I tried to add a few new parameters:

file = open(r'Query.txt','r',encoding='utf-8')

Yet unsuccessful.

Can anyone help me?

asked by anonymous 18.12.2018 / 20:11

1 answer


Maybe because your "Query.txt" file is not in utf-8 ?? Try changing "encoding" to "latin-1" instead of "utf-8":

file = open(r'Query.txt','r',encoding='latin-1')
18.12.2018 / 20:16