Вот как словарь выглядит:
Код: Выделить всё
"gameLog": [
{
"gameId": 2023021306,
"teamAbbrev": "EDM",
"homeRoadFlag": "R",
"gameDate": "2024-04-17",
"goals": 0,
"assists": 0,
"commonName": {
"default": "Oilers"
},
"opponentCommonName": {
"default": "Coyotes"
},
"points": 0,
"plusMinus": -2,
"powerPlayGoals": 0,
"powerPlayPoints": 0,
"gameWinningGoals": 0,
"otGoals": 0,
"shots": 2,
"shifts": 20,
"shorthandedGoals": 0,
"shorthandedPoints": 0,
"pim": 0,
"toi": "17:44",
"opponentAbbrev": "ARI"
},
Я пробовал:
Код: Выделить всё
for key in player_data_json['gameLog']:
goals = 0
for val in key:
if key == 'goals':
goals += key[val]
print(goals)
Подробнее здесь: https://stackoverflow.com/questions/785 ... m-a-sports