一篇文章,先转为单词为元素的列表。
import re
运算结果,['asdf','fjdk','afred','fjek','asdf','foo','sdkk']
在得到分解LIST后,就可以进行单词分析了。要用到Counter工具。
words = [
'look','into','my','eyes','look',
'the','the','not','around',255);"> 'eyes',"don't",255);"> 'my',"you're",'under'
]
from collections import Counter
word_counts = Counter(words)
top_three = word_counts.most_common(3)
print(top_three)
# Outputs [('eyes',8),('the',5),('look',4)]