python中统计各个单词出现的次数使用方法_利用python内置函数,快速统计单词在文本中出现的次数...
#coding=utf-8importcollectionsimportoswithopen('str.txt')asfile1:#打开文本文件str1=file1.read().split('')#将文章按照空格划分开print"原文本:\n%s"%str1print"\n各单词出现的次数:\n%s"%collections.Counter(str1)printco...