python pprint
使用 pprint 模块
pprint 模块( pretty printer )
用于打印 Python 数据结构. 当你在命令行下打印特定数据结构时你会发现它很有用(输出格式比较整齐, 便于阅读).
import json from pprint import pprint with open(r'C:\Temp\aa.json','r') as f: loadfile=json.load(f) pprint(loadfile) print(loadfile) out =========================== RESTART: C:/Temp/t1.py =========================== {'ChannelBusinessHours': {'d': {'e': 'ee'}, 'r': 'fddfdfdf'}, 'name': 'AWQA', 'price': 542.33, 'shares': 100} {'price': 542.33, 'shares': 100, 'name': 'AWQA', 'ChannelBusinessHours': {'r': 'fddfdfdf', 'd': {'e': 'ee'}}} >>>