python列表排重:列表排重并计算字符出现的次数
2014-08-24 16:06 kowme 阅读(815) 评论(0) 编辑 收藏 举报a=[1,2,2,3,4,5,6,8,9,0,0,0] dictc={} for i in range(len(a)): dictc[a[i]]=a.count(a[i]) for key in dictc: print key,dictc[key]
这段代码主要关注两点:1、字典的key是唯一值 2、count函数的使用
发上等愿,结中等缘,享下等福;择高处立,寻平处住,向宽处行
Brick walls are there for a reason :they let us prove how badly we want things
a=[1,2,2,3,4,5,6,8,9,0,0,0] dictc={} for i in range(len(a)): dictc[a[i]]=a.count(a[i]) for key in dictc: print key,dictc[key]
这段代码主要关注两点:1、字典的key是唯一值 2、count函数的使用
It's not who you are underneath, it's what you do that defines you
Brick walls are there for a reason :they let us prove how badly we want things