Advertisement
Uno-Dan

A walk in the park.

Sep 8th, 2019
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1.  
  2. def dump(data, indent=None):
  3.     indent = indent if indent else '.'
  4.  
  5.     print('-------------------------------------------------------------------------------------------------------')
  6.     if data:
  7.         def walk(_data, count):
  8.             count += 1
  9.             for key, value in _data.items():
  10.                 if isinstance(value, dict):
  11.                     print(indent * count, key)
  12.                     walk(value, count)
  13.                 else:
  14.                     if isinstance(value, str):
  15.                         value = f'"{value}"'
  16.                     print(indent * count, key, f'value={value}')
  17.  
  18.         walk(data, 0)
  19.     else:
  20.         print(' (No Data)')
  21.  
  22.     print('-------------------------------------------------------------------------------------------------------')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement