Test json.py

>>> json.dump(rec, fp=open('testjson.txt', 'w'), indent=4) >>> print(open('testjson.txt').read()) { "job": [ "dev", "mgr" ], "name": { "last": "Smith", "first": "Bob" }, "age": 40.5 } >>> P = json.load(open('testjson.txt')) >>> P {'job': ['dev', 'mgr'], 'name': {'last': 'Smith', 'first': 'Bob'}, 'age': 40.5}
It’s similarly straightforward to translate Python objects to and from JSON data strings in files. Prior to being stored in a file, your data is simply Python objects; the JSON module recreates them from the JSON textual representation when it loads it from the file

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.