Instruction
In this part, we learned how to:
- Convert a Python object into a JSON string:
json.dumps(data)
- Get better-looking print results:
json.dumps(data, sort_keys=True, indent=4, separators=('.', ',')) - Save data to a JSON file:
with open('file_name.json', 'w') as outfile: json.dump(data, outfile)
Before we move on to the next part, let's do one more exercise!
Exercise
Click to continue.



