xyzg198891的个人博客分享 http://blog.sciencenet.cn/u/xyzg198891

博文

按标题搜索
Python统计单词频数
2016-11-4 11:51
import re from collections import Counter #define a function to print the result by line def printByLine(tuples): return( 'n'.join(' '.join(map(str,t)) for t in tuples)) #define a function to print the result alphabetically def countsSortedAlphabetically(c ...
个人分类: Python|2354 次阅读|没有评论
Python统计字母频数和频率
2016-11-3 23:10
方案一 统计字符串中的字母频数 import collections import re d = collections.defaultdict(int) S = testTypecopyri4g3HACBCtcFor the ginpraise.ll be dog ssditsl-+-___*^%icense()ation. #convert to lower case s = S.lower() #match non-letter chars rule = re.compile(r ) #dele ...
个人分类: Python|9700 次阅读|没有评论

本页有 8 篇博文因作者的隐私设置或未通过审核而隐藏

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-26 17:42

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部