I am working with a Twitter library that downloads tweets and allows their subsequent treatment.
The problem is that the accents and other special characters are shown to me in the following way:
La aplicaci\xf3n de un modelo educativo
instead of
La aplicación de un modelo educativo
I have been researching the forums and I have found a solution that would be:
tweet="La aplicaci\xf3n de un modelo educativo";
tweet = tweet.encode("utf-8");
But I haven't been able to get it to work.
Any ideas?
Your string is initially ISO 8859-1/Latin-1 (
\xf3n
) encoded, not UTF-8 (\xc3\xb3n
). On the other hand you have a string of bytes and you want to get a unicode string , you must decode (decode
) the string, not useencode
:We can re-encode the string to get back an object
str
but this time using utf-8:Online example:
https://repl.it/@FJSevilla/decoding