Can json.dumps create multiple lines
Tim Chase
python.list at tim.thechases.com
Thu Dec 1 11:58:24 EST 2016
On 2016-12-01 17:30, Cecil Westerhof wrote:
> When I have a value dummy which contains:
> ['An array', 'with several strings', 'as a demo']
> Then json.dumps(dummy) would generate:
> '["An array", "with several strings", "as a demo"]'
> I would prefer when it would generate:
> '[
> "An array",
> "with several strings",
> "as a demo"
> ]'
>
> Is this possible, or do I have to code this myself?
print(json.dumps(['An array', 'with several strings', 'as a demo'],
indent=0))
for the basics of what you ask, though you can change indent= to
indent the contents for readability.
-tkc
More information about the Python-list
mailing list