Python计算-对列表元素分类统计

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

list = ['a', 'b', 'c', 'a', 'c', 'a']
res = {}
for each in list:
    res[each] = res.get(each, 0) + 1
for each in res:
    print each,  # 元素
    print res[each]  # 计数