小手轻轻一挥,python格式化输出美丽的json数据

    xiaoxiao2022-07-04  113

    python 格式化输出 json 数据

    # -*- coding: utf-8 -*- import json data= { "msg": { "crc": 0, "msg_body": "How are you ?", "msg_len": 88, "recv_id": 319371, "send_id": 319371, "send_time": 0, "type": 96 }, "msgLen":90 } print(json.dumps(data, sort_keys=True, indent=2)) # 排序并且缩进两个字符输出

    运行结果

    { "msg": { "crc": 0, "msg_body": "How are you ?", "msg_len": 88, "recv_id": 319371, "send_id": 319371, "send_time": 0, "type": 96 }, "msgLen": 90 }
    最新回复(0)