Answer the question
In order to leave comments, you need to log in
It is written to a json file in a different encoding, although I set ensure_ascii=False. What to do?
I want to make it so that a dictionary with data about a person is recorded. Here is the code:
import json
start = {
"money":"100",
"reputation":"0",
"rank":"Нет",
"devices":"Нет",
"Донат":"Нет"
}
dict.update([(id, start)])
with open('main.json', 'w', encoding="utf-8") as file:
json.dump(dict, file, ensure_ascii=False, indent=4)
{
"484175786": {
"money": "100",
"reputation": "0",
"rank": "None",
"devices": "Нет",
"Донат": "Нет"
}
}
Answer the question
In order to leave comments, you need to log in
If you open utf-8 as windows-1251, then that's exactly what it will be.
Everything is already written in UTF-8 without any ensure_ascii=False
. Non-ASCII characters can be encoded as \uXXXX when written to JSON
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question