热线电话:13121318867

登录
2019-07-02 阅读量: 710
collections模块下的工具类
"""
找出序列中出现次数最多的元素
"""
from collections import Counter

words = [
'look', 'into', 'my', 'eyes', 'look', 'into', 'my', 'eyes',
'the', 'eyes', 'the', 'eyes', 'the', 'eyes', 'not', 'around',
'the', 'eyes', "don't", 'look', 'around', 'the', 'eyes',
'look', 'into', 'my', 'eyes', "you're", 'under'
]
counter = Counter(words)
print(counter.most_common(3))
0.0000
3
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子