Answer the question
In order to leave comments, you need to log in
How to correctly print unicode characters to a file in python?
The essence of the question is this: I print a json structure containing Russian letters in a file, when I open the file, instead of Russian letters, I see unicode encoded characters (\u...). Tell me how to write to a file, so that then exactly the necessary characters are displayed and not their codes, or an editor that can translate this business (for linux (except np++ on vine)).
I print like this:
with open(path, 'w+') as f:
json.dump(data, f, indent=2)
Answer the question
In order to leave comments, you need to log in
with open(path, 'w+') as f:
f.write(json.dumps(data, indent=2, ensure_ascii=False).encode('utf-8'))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question