这是我的json。
initiated with options {'record_id': 335, 'backup_config_id': 28, 'attachement_type': 3,
'instance_id': 48, 'volumes': [{'aws_instance_id': 'xyz', 'aws_instance_name': 'abc', 'instance_record_id': 48, 'aws_region': 'ap-southeast-2',
'aws_volume_id': 'abc', 'aws_snapshot_id': 'snap-123',
'aws_zone': 'ap-southeast-2b', 'aws_capacity': 16, 'aws_device': '/dev/sda1', 'volume_type': 'gp2', 'iops': 100,
'encrypted': False, 'delete_on_termination': False, 'end_time': '2020-05-09T16:18:55.962000Z', 'success': 1,
'deletion_time': None, 'aws_root_device': '/dev/sda1',
'volume_id': 'vol-123', 'device': '/dev/sda1'}, {'aws_instance_id': 'i-123',
'aws_instance_name': 'abc', 'instance_record_id': 48,
'aws_region': 'ap-southeast-2', 'aws_volume_id': 'vol-123',
'aws_snapshot_id': 'snap-123', 'aws_zone': 'ap-southeast-2b', 'aws_capacity': 16, 'aws_device': '/dev/sdh', 'volume_type': 'gp2', 'iops': 100, 'encrypted': False, 'delete_on_termination': False, 'end_time': '2020-05-09T16:18:55.962000Z', 'success': 1, 'deletion_time': None, 'aws_root_device': '/dev/sda1','volume_id': 'vol-123', 'device': '/dev/sdh'}], 'aws_instance': 'i-123'}
用户无法理解。我想在python中使其可读。
怎么做?
3条答案
按热度按时间jecbmhm31#
python中的json模块已经实现了一些基本的漂亮打印,并使用了python参数:
r9f1avp52#
漂亮的印花,pprint is one way to do it
0ejtzxu13#
@Darshit Kothari回答对我不起作用,所以我试着