Default accents when passing data from a txt to a Python list

Asked

Viewed 79 times

2

I have a python script that takes words from a ". txt" file through the open method and puts them in a list. However, if the word in the text file has some accent, when passed to the list in python the accent turns "Äe" for example. I’d like to know how I can stop that problem from happening.

txt file

Até! Tchau! Nunca é um adeus! Fui!

Python excerpt

chats = open('dialogo/'+ arquivos, 'r').readlines()

When I give print() on the chat list, accentuated characters come defaced from txt file.

  • Python by default opens the file with UTF-8 encoding. The file was created with this encoding?

  • Yes, the encoding is already in UTF-8...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.