Uno-Dan

Your Future

Sep 4th, 2019
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.22 KB | None | 0 0
  1.  
  2. data = {
  3.     'leve1_1': {
  4.         'leve1_2': {
  5.             'leve1_3': {
  6.                 'leve1_4': {
  7.                     'item1': 10,
  8.                     'item2': 20,
  9.                 }
  10.             }
  11.         }
  12.     }
  13. }
  14.  
  15. print(data['leve1_1']['leve1_2']['leve1_3']['leve1_4']['item1'])
  16. print(data['leve1_1']['leve1_2']['leve1_3']['leve1_4']['item2'])
  17.  
  18.  
  19. # Access all your data via uri like "leve1_1/leve1_2/leve1_3/leve1_4/item1".
  20.  
  21. # When it's stored in a cache or is addressable, you will have no longer need to access static
  22. # data as in. "data['leve1_1']['leve1_2']['leve1_3']['leve1_4']['item2']", like above.
  23. # The reason for this is beyond the scope of this short message.
  24.  
  25. # Now here is something for you to do that would be better for you to learn than what you are doing.
  26. # Write two functions to drill into the dict above and read and write to it.
  27. # The two commented lines below are what you need to make work.
  28. # This is a basic 101 coding for any coder or they are not one,
  29. # if you can't or don't want to write it this is not your field.
  30.  
  31. print(cache.get('leve1_1/leve1_2/leve1_3/leve1_4/item1'))
  32. cache.set('leve1_1/leve1_2/leve1_3/leve1_4/item1', 100)
  33. print(cache.get('leve1_1/leve1_2/leve1_3/leve1_4/item1'))
Advertisement
Add Comment
Please, Sign In to add comment