![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
有关学习
文章平均质量分 62
aonanyang
这个作者很懒,什么都没留下…
展开
-
python统计复杂文本文档中单词频率(效果不好,不能去掉每行开头的两个‘空格’一样的东东(不是空格,不知道是什么),然后里面一些奇怪的字符页不能去掉 ,“mission.txt”为要统计的文本,)
#encoding:utf-8import stringd={}char="!\"\'‘() —…“”*,-./:;?[\\]{|}~"identify = string.maketrans('', '')result_name=r".\\test_result.txt"file_name=r".\\mission.txt"f=open(file_name,'r')r=open(原创 2014-04-30 15:59:38 · 937 阅读 · 0 评论 -
python统计文本中单词个数
#!/usr/bin/env python file_name="hello.txt"line_counts=0word_counts=0char_counts=0file=open(file_name,"r")for line in file.readlines(): words=line.split(' ') line_counts+=1 word_原创 2014-04-11 15:55:16 · 4477 阅读 · 0 评论