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

2015-09-05 0 688
Python计算-对列表元素分类统计
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]  # 计数

遇见资源网 python Python计算-对列表元素分类统计 http://www.ox520.com/15771.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务