标签:blog log foo nts logs ict color pre nbsp
1 from collections import defaultdict 2 3 a=[1,1,2,2,2,2,3,3,4,5,5,5,9,9,9] 4 5 def foo(a): 6 counts=defaultdict(int) 7 for x in a: 8 counts[x]+=1 9 print(counts) 10 return counts 11 12 foo(a)
标签:blog log foo nts logs ict color pre nbsp
原文地址:http://www.cnblogs.com/chedanlangren/p/7400600.html