我正在处理一些应该运行的代码。但是,我继续得到
匹配匹配['匹配']: KeyError:'matches'
,应该有一个值。我已经检查/双重检查以确保它返回一个值。
def handle_data(self, data):
players = data
teams = {}
myStats = []
enStats = []
# Seperate the players by team
for player in players:
if player["teamId"] == 100:
teams.setdefault("team A", []).append(player)
else:
teams.setdefault("team B", []).append(player)
if self.check_team(teams['team A']):
self.find_my_lane(teams['team A'])
self.find_e_lane(teams['team B'])
else:
self.find_my_lane(teams['team B'])
self.find_e_lane(teams['team A'])
def find_my_lane(self, team):
lane_list = {}
for player in team:
if player['summonerId'] == self.summoner_id:
self.champion_id = player['championId']
matches = self.get_match_list(self.summoner_id, self.champion_id)
for match in matches['matches']:
if match['lane'] in lane_list:
lane_list[match['lane']] += 1
else:
lane_list[match['lane']] = 1
for lane in lane_list:
rate = (float(lane_list[lane]) / len(matches['matches'])) * 100
if rate > 40.0:
self.lane.append(lane)
break
def find_e_lane(self, team):
"""
:rtype : object
"""
e_lane_list = []
lane_opp = []
e_matches = {}
assert isinstance(team, object)
for player in team:
e_matches = self.get_match_list(player['summonerId'], player['championId'])
for match in e_matches['matches']:
if match['lane'] in e_lane_list:
e_lane_list[match['lane']] += 1
else:
e_lane_list[match['lane']] = 1
for e_lane in e_lane_list:
rate = (float(e_lane_list[e_lane]) / len(e_matches['matches'])) * 100
if (40.0 < rate) and (e_lane in self.lane):
lane_opp.append(player['summonerId'])
lane_opp.append(player['championId'])
if not lane_opp:
continue
else:
break
self.e_summoner = lane_opp[0]
self.e_champion = lane_opp[1]
如果您需要任何细节或规格,我可以提供