How to fix encoding in python?

Hi all.
Need help with encoding.
The input comes as Cyrillic and Latin.
Tried # -*- coding: utf-8 -*- and # -*- coding: cp1251 -*-

folder_name = str(i.text).encode().decode('utf-8')
print(folder_name)

2b22f9b7a9383dc4c5941d5bf975ebd9.jpg
folder_name = str(i.text).encode().decode('cp1251')
print(folder_name)

4c4d737ecfb26315c98b60ddd3b446cd.jpg

What is the solution?
July 2nd 19 at 14:06
2 answers
July 2nd 19 at 14:08
After 3 hours of dances with a tambourine, managed to escape from the problem.
Replacing the query page requests.get(url).text
on urllib.request.urlopen(url).read()
You changed the text output to the output bytes. And I could just make requests.get(url).content - glennie_Mer commented on July 2nd 19 at 14:11
July 2nd 19 at 14:10
The input comes as Cyrillic and Latin.
Tried # -*- coding: utf-8 -*- and # -*- coding: cp1251 -*-

The Declaration of encoding in General does not apply to what comes. This Declaration tells the interpreter which encoding contains the source code (to the interpreter incorrectly unescape it).

Find more questions by tags Python