last one for the night, want to see what clever ways there are with python to add all of the 'count' values from the following type 开发者_如何学编程of dictionary:
{0: {'count': 1000}, 1: {'count': 2000}}
so the end result should be an int value of 3000.
>>> x = {0: {'count': 1000}, 1: {'count': 2000}}
>>> sum(v['count'] for v in x.values())
3000
A shorter one:
sum(d[k]['count'] for k in d)
sum(i['count'] for i in d.values())
How about using reduction in python?
reduce(lambda x,y: x+y, [v['count'] for v in a.values()])
精彩评论