The example above prints a JSON string, but it is not very easy to read, with no indentations and line breaks.
The json.dumps()
method has parameters to make it easier to read the result:
Use the indent
parameter to define the numbers of indents:
json.dumps(x, indent=4)
You can also define the separators, default value is (", ", ": "), which means using a comma and a space to separate each object, and a colon and a space to separate keys from values:
ExampleUse the separators
parameter to change the default separator:
json.dumps(x, indent=4, separators=(". ", " = "))
Track your progress - it's free!
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4