python2.7,输入一个字符串,统计其中每个字符出现的次数,使用列表及字符串函数

更新时间:02-09 教程 由 稚情 分享

str=input("请输入一串字符")

str1=str.lower()

str2={}

foriinstr1:

str2[i]=str1.count(i)

print(str2)

str=input("请输入一串字符")

str1=str.lower()

str2={}

foriinstr1:

str2[i]=str1.count(i)

print(str2)

声明:关于《python2.7,输入一个字符串,统计其中每个字符出现的次数,使用列表及字符串函数》以上内容仅供参考,若您的权利被侵害,请联系13825271@qq.com
本文网址:http://www.25820.com/tutorial/14_2105665.html