python python中的漂亮(或漂亮打印)JSON对象具有这一功能。在尝试了解什么时,我总是使用这个片段

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python python中的漂亮(或漂亮打印)JSON对象具有这一功能。在尝试了解什么时,我总是使用这个片段相关的知识,希望对你有一定的参考价值。

def prettyfy(input_json, desired_indent=4):
    # returns a prettyfied string of a json object
    # by: codykochmann
    from json import dumps
    return dumps(input_json, sort_keys=True, indent=desired_indent, separators=(',', ': '))

以上是关于python python中的漂亮(或漂亮打印)JSON对象具有这一功能。在尝试了解什么时,我总是使用这个片段的主要内容,如果未能解决你的问题,请参考以下文章