import json data = {"key": "value"} with open('data.json', 'w') as jsonfile: json.dump(data, jsonfile)
import json with open('data.txt') as json_file: data = json.load(json_file)
>>> jstr = json.dumps(data, ensure_ascii=False, indent=4) >>> print(jstr) { "item": "Beer", "cost": "£4.00" }