-1
我具有相等長度的Python字典的任意數量的具有匹配的密鑰組,其是列表,這樣的列表:總和蟒字典內的一個對應的列表元素
[{'Item 1':[5.25, 'Red', 'Large'], 'Item 2':[8.50, 'Blue', 'Small'], 'Item 3':[12.50, 'Tan', 'Medium']},
{'Item 1':[10.50, 'Red', 'Large'], 'Item 2':[14.25, 'Blue', 'Small'], 'Item 3':[17.25, 'Tan', 'Medium']},
{'Item 1':[12.25, 'Red', 'Large'], 'Item 2':[20.25, 'Blue', 'Small'], 'Item 3':[24.25, 'Tan', 'Medium']}]
用於每個屬性的列表產品是相同的,除了第一個項目,一個int或float。
如何獲得具有相同組鍵和相同組值的單個字典,但列表中的第一項是相加的?換句話說,我想回到:
{'Item 1':[28.00, 'Red', 'Large'], 'Item 2':[43.00, 'Blue', 'Small'], 'Item 3':[54.00, 'Tan', 'Medium']}
完美的作品!感謝您的時間。 –