Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- data = {
- 'leve1_1': {
- 'leve1_2': {
- 'leve1_3': {
- 'leve1_4': {
- 'item1': 10,
- 'item2': 20,
- }
- }
- }
- }
- }
- print(data['leve1_1']['leve1_2']['leve1_3']['leve1_4']['item1'])
- print(data['leve1_1']['leve1_2']['leve1_3']['leve1_4']['item2'])
- # Access all your data via uri like "leve1_1/leve1_2/leve1_3/leve1_4/item1".
- # When it's stored in a cache or is addressable, you will have no longer need to access static
- # data as in. "data['leve1_1']['leve1_2']['leve1_3']['leve1_4']['item2']", like above.
- # The reason for this is beyond the scope of this short message.
- # Now here is something for you to do that would be better for you to learn than what you are doing.
- # Write two functions to drill into the dict above and read and write to it.
- # The two commented lines below are what you need to make work.
- # This is a basic 101 coding for any coder or they are not one,
- # if you can't or don't want to write it this is not your field.
- print(cache.get('leve1_1/leve1_2/leve1_3/leve1_4/item1'))
- cache.set('leve1_1/leve1_2/leve1_3/leve1_4/item1', 100)
- print(cache.get('leve1_1/leve1_2/leve1_3/leve1_4/item1'))
Advertisement
Add Comment
Please, Sign In to add comment