每天CookBook之Python-012

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'
]

words_counts = Counter(words)
top_one = words_counts.most_common(10)
print(top_one)

print(words_counts['not'])
print(words_counts['eyes'])

[('eyes', 8), ('the', 5), ('look', 4), ('my', 3), ('into', 3), ('around', 2), ("
don't", 1), ('not', 1), ('under', 1), ("you're", 1)]
1
8
posted @ 2016-07-09 09:46  4Thing  阅读(77)  评论(0编辑  收藏  举报