马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
{'fileName': 'hero_list.js',
'fileTime': '2020-04-17 10:24:12',
'hero': [{'alias': 'Annie',
'attack': '2',
'banAudio': 'https://game.gtimg.cn/images/lol/act/img/vo/ban/1.ogg',
'defense': '3',
'difficulty': '6',
'heroId': '1',
'isWeekFree': '0',
'magic': '10',
'name': '黑暗之女',
'roles': ['mage'],
'selectAudio': 'https://game.gtimg.cn/images/lol/act/img/vo/choose/1.ogg',
'title': '安妮'},
{'alias': 'Olaf',
'attack': '9',
'banAudio': 'https://game.gtimg.cn/images/lol/act/img/vo/ban/2.ogg',
'defense': '5',
'difficulty': '3',
'heroId': '2',
'isWeekFree': '0',
'magic': '3',
'name': '狂战士',
'roles': ['fighter', 'tank'],
'selectAudio': 'https://game.gtimg.cn/images/lol/act/img/vo/choose/2.ogg',
'title': '奥拉夫'},
-------------------------------------------------------------{'alias': 'Sett',
'attack': '8',
'banAudio': 'https://game.gtimg.cn/images/lol/act/img/vo/ban/875.ogg',
'defense': '5',
'difficulty': '2',
'heroId': '875',
'isWeekFree': '0',
'magic': '1',
'name': '腕豪',
'roles': ['fighter', 'tank'],
'selectAudio': 'https://game.gtimg.cn/images/lol/act/img/vo/choose/875.ogg',
'title': '瑟提'}],
'version': '10.8'}
上面是头部尾部数据,下面是我打算写的import requests
import pprint
import json
url = 'https://game.gtimg.cn/images/lol/act/img/js/heroList/hero_list.js'
req = requests.get(url)
data = req.json()
pprint.pprint(data)
然后打算遍历data这个数据,他是字典的形式,假设我想访问attack数据,我应该怎么遍历,脑壳子疼
for item in data['hero']:
print(item['attack'])
|