假设我有一本字典,如下所示:dictionary1 = {
"Scientology": {
"source": "LRH",
"scilon 1": {
"name": "John Travolta",
"OT level": 5,
"wall of fire": True
},
"scilon 2": {
"name": "Tom Cruise",
"OT level": 6,
"wall of fire": True
}
}
}
我希望能够在对齐的列中打印此词典和其他不同深度的词典,如下所示:
^{pr2}$
我知道pprint方法。它会生成如下打印输出:>>> pprint.pprint(dictionary1)
{'Scientology': {'scilon 1': {'OT level': 5,
'name': 'John Travolta',
'wall of fire': True},
'scilon 2': {'OT level': 6,
'name': 'Tom Cruise',
'wall of fire': True},