Advertisement
smithy1208

python_json

Apr 11th, 2021
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. [smithy@smithy-gg tmp]$ ipython
  2. Python 3.8.7 (default, Jan 20 2021, 00:00:00)
  3. Type 'copyright', 'credits' or 'license' for more information
  4. IPython 7.18.1 -- An enhanced Interactive Python. Type '?' for help.
  5.  
  6. In [1]: import json
  7.  
  8. In [2]: with open("1.json") as f:
  9. ...: data = json.load(f)
  10. ...:
  11.  
  12. In [3]: data
  13. Out[3]:
  14. {'menu': {'id': 'file',
  15. 'value': 'File',
  16. 'popup': {'menuitem': [{'value': 'New', 'onclick': 'CreateNewDoc()'},
  17. {'value': 'Open', 'onclick': 'OpenDoc()'},
  18. {'value': 'Close', 'onclick': 'CloseDoc()'}]}}}
  19.  
  20. In [4]: data["menu"]["popup"]
  21. Out[4]:
  22. {'menuitem': [{'value': 'New', 'onclick': 'CreateNewDoc()'},
  23. {'value': 'Open', 'onclick': 'OpenDoc()'},
  24. {'value': 'Close', 'onclick': 'CloseDoc()'}]}
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement