你好,更新的代码和结果如下inputStr="adhdbxhsjjsbbsxjdjjebbxbsheuhdbbd"
ResultDict={}
for index in range(len(inputStr)):
if inputStr[index] in ResultDict:
ResultDict[inputStr[index]] +=1
else:
ResultDict[inputStr[index]]=1
for each in sorted(ResultDict.keys()):
print(each + " " +str(ResultDict[each]))
print (sorted(ResultDict.items(), key=lambda x: x[1]))
第一排序结果
a 1
b 8
d 5
e 2
h 4
j 5
s 4
u 1
x 3
第二排序的结果
[('a', 1), ('u', 1), ('e', 2), ('x', 3), ('h', 4), ('s', 4), ('d', 5), ('j', 5), ('b', 8)]
最后
以上就是淡定星月最近收集整理的关于python英文字符频率统计_Python 统计字母出现频率的全部内容,更多相关python英文字符频率统计_Python内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复