【发布时间】:2016-12-08 00:31:44
【问题描述】:
我有这样的字典:
dict = [{'a':2, 'b':3}, {'b':4}, {'a':1, 'c':5}]
我需要获取所有不同键的平均值。结果应如下所示:
avg = [{'a':1.5, 'b':3.5, 'c':5}]
我可以获得所有键的摘要,但我没有意识到如何计算相同的键以获得平均数。
【问题讨论】:
-
那个变量
dict是字典的list。
标签: python dictionary average