HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
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:
Use the separators
parameter to change the
default separator:
json.dumps(x, indent=4, separators=(". ", " = "))