Is there an easy way of iterating over nested dictionary, which may consist of other objects like lists, tuples, then again dictionaries so that iteration covers all the elements of these other objects?
For example, if I type a key of a nested dictionary object, I would get it all listed in the Python interpreter.
[edit] here is example dictionary:
{
'key_1': 'value_1',
'key_2': {'key_21': [(2100, 2101), (2110, 2111)],
'key_22': ['l1', 'l2'],
'key_23': {'key_231': 'v'},
'key_24': {'key_241': 502,
'key_242': [(5, 0), (7, 0)],
'key_243': {'key_2431': [0, 0],
'key_2432': 504,
'key_2433': [(11451, 0), (11452, 0)]
},
'key_244': {'key_2441': {'key_24411': {'key_244111': 'v_24411',
'key_244112': [(5549, 0)]
},
'key_24412':'v_24412'
},
'key_2441': ['ll1', 'll2']
}
},
}
}
sorry for being unreadable, but I did the best that I could.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…