我制作了我的版本JSON对象的副本,因为在迭代它时从列表中删除项将导致ValueError,因此副本将具有与releases_data相同的JSONObjects,但是现在当我尝试从中删除JSONObject时列表副本我得到:
self.releases_data_copy.remove(x)的 ValueError:list.remove(x):x不在列表中
releases_data = []
releases_data_copy = []
#code omitted
self.releases_data_copy = self.releases_data
for x in self.releases_data:
for i in self.games_data:
if x['game']['id'] == i['id']:
data = {'releases_object': x, 'games_object': i}
self.grouped_data['results'].append(data.copy())
self.releases_data_copy.remove(x)