Answer the question
In order to leave comments, you need to log in
Working with json files?
def g():
with open('days.txt', 'r') as f:
return json.loads(f.read())
j = g()
with open('days_file.txt', 'w') as fileQ:
json.dump(j, fileQ, indent=4, ensure_ascii=False)
"{\n \"amount\": 2,\n \"hash\": \"6d0d56cbb80fe275ebfdf8e84ee475a5\",\n \"name\": \"ivan\",\n \"to_whom\": \"katja\",\n \"uuid\": \"000\"\n}"
{
"amount": 2,
"hash": "6d0d56cbb80fe275ebfdf8e84ee475a5",
"name": "ivan",
"to_whom": "katja",
"uuid": "000"
}
Answer the question
In order to leave comments, you need to log in
import json
with open('days_file.txt') as file:
j_data = json.loads(file.read())
json_formatted = json.dumps(j_data, indent=2)
print(json_formatted)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question