Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # https://repl.it/languages/python3
- import json
- data = '''
- [
- { "id" : "001",
- "x" : "2",
- "name" : "Chuck"
- } ,
- { "id" : "009",
- "x" : "7",
- "name" : "Brent"
- }
- ]
- '''
- info = json.loads(data)
- print('User count:', len(info))
- # what we get from json.loads() is a Python list which we traverse with
- # a for loop, and each item within that list is a Python dictionary.
- for item in info:
- print('-Name', item['name'])
- print('-Id', item['id'])
- print('-x', item['x'])
Advertisement
Add Comment
Please, Sign In to add comment