统计文章词频

from collections import Counter
import re

txt = open('app.py').read()
print Counter(re.split('\W+',txt)).most_common(3)

re.split('\W+',txt)表示以非单词字符划分。
posted @ 2017-08-09 15:05  赭山东路  阅读(90)  评论(0编辑  收藏  举报