Python3.6
riot apiというapiから勝率などを計算するためゲームの対戦データを取得しました。
LOLというゲームで10人、5vs5で行う対戦ゲームです。
プレイヤー1~10の全て情報の中から
8項目のデータを取得したいのです。
取得したデータはこの様な形で書かれています。
[{ 'gameId': 3194473783, 'platformId': 'KR', 'gameCreation': 1525506476785, 'gameDuration': 1751, 'queueId': 420, 'mapId': 11, 'seasonId': 11, 'gameVersion': '8.9.228.4283', 'gameMode': 'CLASSIC', 'gameType': 'MATCHED_GAME', 'teams': [{ 'teamId': 100, 'win': 'Fail', 'firstBlood': False, 'firstTower': False, 'firstInhibitor': False, 'firstBaron': False, 'firstDragon': False, 'firstRiftHerald': False, ・ ・ ・ このように続きます。
変数 match_detailにデータを格納
格納したデータから必要な項目を一つづつ取り出すとこうなります。
これをまとめて、10人分取り出すにはどのような式になるでしょうか?
よろしくおねがいいたします。
python
1a1 = match_detail[0]['gameId'] 2b1 = match_detail[0]['participants'][0]['participantId'] 3c1 = match_detail[0]['participants'][0]['teamId'] 4d1 = match_detail[0]['participants'][0]['championId'] 5e1 = match_detail[0]['participants'][0]['stats']['win'] 6f1 = match_detail[0]['participants'][0]['timeline']['lane'] 7g1 = match_detail[0]['participantIdentities'][0]['player']['summonerId'] 8# #player1の情報 9 10 11a2 = match_detail[0]['gameId'] 12b2 = match_detail[0]['participants'][1]['participantId'] 13c2 = match_detail[0]['participants'][1]['teamId'] 14d2 = match_detail[0]['participants'][1]['championId'] 15e2 = match_detail[0]['participants'][1]['stats']['win'] 16f2 = match_detail[0]['participants'][1]['timeline']['lane'] 17g2 = match_detail[0]['participantIdentities'][1]['player']['summonerId'] 18# #player2の情報 19 20print(a1, b1, c1, d1, e1, f1, g1,) 21#3194473783 1 100 163 False MIDDLE 9314645 22 23print(a2, b2, c2, d2, e2, f2, g2,) 24#3194473783 2 100 121 False JUNGLE 69620201 25 26
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/05/06 08:40
2018/05/06 08:46
2018/05/06 08:54
2018/05/06 08:58
2018/05/06 09:09