如果我有我從不同規模合併兩個大小不同的詞典和不同的價值觀
dictionary1:
{'id': 1 , 'passCount': 3}, {'id': 2 , 'passCount': 4}, {'id': 5 , 'passCount': 7}, {'id': 6, 'passCount': 3}
dictionary2:
{'id': 1 , 'failCount': 1}, {'id': 3 , 'failCount': 2}, {'id': 5 , 'failCount': 3}
最初的查詢創建了兩個不同的字典,我創建這兩個字典的主列表:
List = []
for i in dictionary1:
for j in dictionary2:
if i['id'] = j['id]:
List.append[i['id'],i['passCount'],j['failCount']]
else:
List.append[i['id'],i['passCount'],0]
List.append[j['id'],0, j['failCount']
return List
當我將這個列表打印出來用於我的數據時,我只會得到一個匹配的id列表,而不會考慮其他列表。
出於這個原因,我想打印一本字典在那裏我能得到它的打印
{'id' = 1, 'passCount' = 3, 'failCount' = 1}, {'id': 2 , 'passCount': 4, 'failCount' = 0}...
等,但不刪除任何標識的
致謝
結構含有'dictionary1','dictionary2'無效 – RomanPerekhrest