-
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 篇博文因作者的隐私设置或未通过审核而隐藏