Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [
- {
- "id": 1,
- "name": "Bulbasaur",
- "type": [
- "grass",
- "poison"
- ]
- },
- {
- "id": 2,
- "name": "Ivysaur",
- "type": [
- "grass",
- "poison"
- ]
- }
- ]
- ["Bulbasaur","Ivysaur"]
- import json
- try:
- with open("./simple.json", 'r') as f:
- contents = json.load(f)
- except Exception as e:
- print(e)
- print(contents[:]["name"])
- contents = [
- {
- "id": 1,
- "name": "Bulbasaur",
- "type": [
- "grass",
- "poison"
- ]
- },
- {
- "id": 2,
- "name": "Ivysaur",
- "type": [
- "grass",
- "poison"
- ]
- }
- ]
- li = []
- for item in contents:
- li.append(item.get('name'))
- print([d["name"] for d in contents])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement