mirror of
https://github.com/kennethreitz/dive-into-python3.git
synced 2026-06-05 23:10:17 +00:00
clarify json indent explanation
This commit is contained in:
+1
-1
@@ -353,7 +353,7 @@ def protocol_version(file_object):
|
||||
<samp class=p>>>> </samp><kbd class=pp>with open('basic-pretty.json', mode='w', encoding='utf-8') as f:</kbd>
|
||||
<a><samp class=p>... </samp><kbd class=pp> json.dump(basic_entry, f, <mark style="display:inline">indent=2</mark>) <span class=u>①</span></a></kbd></pre>
|
||||
<ol>
|
||||
<li>If you pass an <var>indent</var> parameter to the <code>json.dump()</code> function, it will make the resulting <abbr>JSON</abbr> file more readable, at the expense of larger file size. The <var>indent</var> parameter is an integer. 0 means “put each value on its own line.” A number greater than 0 means “put each value on its own line, and indent that many spaces.”
|
||||
<li>If you pass an <var>indent</var> parameter to the <code>json.dump()</code> function, it will make the resulting <abbr>JSON</abbr> file more readable, at the expense of larger file size. The <var>indent</var> parameter is an integer. 0 means “put each value on its own line.” A number greater than 0 means “put each value on its own line, and use this number of spaces to indent nested data structures.”
|
||||
</ol>
|
||||
|
||||
<p>And this is the result:
|
||||
|
||||
Reference in New Issue
Block a user