我有以下数据结构:
{'row_errors': {'hello.com': {'template': [u'This field is required.']}}}
当我在Python中使用pprint
时,我得到的结果是
{'row_errors': {'hello.com': {'template': [u'This field is required.']}}}
然而,我非常希望它能够像这样打印出来:
{'row_errors':
{'hello.com':
{'template': [u'This field is required.']}}}
这个能通过pprint
进行配置吗?
我更喜欢使用pprint
,因为我要在Jinja模板中打印它。
import json; print(json.dumps(d, indent=4))
。 - wimpprint()
并不十分可配置。 - Martijn Pieterspprint(..., width=40)
。然而,结果并不完全符合您所需的。 - GIZ