Reputation: 487
I write some string on another language and save it to xml file, but the strings looks like
# A part of the xml: recipientname="Калик Мамадо.."
tree.write(new_file_name) # Tree is a xml (ElementTree.parse(file))
with open(new_file_name, 'r') as xml_document:
xml = xml_document.read().replace('\n', '')
How i can decode it to normal string?
Upvotes: 0
Views: 303
Reputation: 614
That's to be excepted. These characters are encoded, they will be displayed and read in correctly. While you can use Cyrillic directly in your text, it will be rendered as unicode entities when written to file.
Upvotes: 0
Reputation: 656
These are no bytes, its HyperText Markup Language https://docs.python.org/3/library/html.html
You can use:
import html
x = html.unescape("ад")
print(x) # This gives ---> ад
Edit, you can just pass the whole file in the function.
Upvotes: 1