Showing posts with label indenting. Show all posts
Showing posts with label indenting. Show all posts

Saturday, July 14, 2018

How do you convert from Python to JSON in Python 3.70b2?

You should import json and use dumps() as shown.

Here data is a python list and it will be converted to json.

json_0

If you want to print it pretty you could do  like this here.

json_1

We started with a sorted list what if we did not, as in data2



json_2