Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
Writing to a JSON file
Summary
8. Summary

Instruction

In this part, we learned how to:

  1. Convert a Python object into a JSON string:
    json.dumps(data)
  2. Get better-looking print results:
    json.dumps(data, sort_keys=True, indent=4, separators=('.', ','))
  3. 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 Next exercise to continue.