Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

walk nested dict python

from benedict import benedict

d = benedict({'dict1': {'foo': 1, 'bar': 2}, 'dict2': {'baz': 3, 'quux': 4}})

def traverse_item(dct, key, value):
   print('key: {} - value: {}'.format(key, value))

d.traverse(traverse_item)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #walk #nested #dict #python
ADD COMMENT
Topic
Name
2+2 =