1:已知字符串 str= 'skdaskerkjsalkj',请统计该字符串中各字母出现的次数
思路是:用字典
str='skdaskerkjsalkj'标签:python,编程,skdaskerkjsalkj,面试,str,字符串 From: https://www.cnblogs.com/vip01/p/16745814.html
a=dict()
for i in str:
if i not in a.keys():
a[i]=1
else:
a[i]=a[i]+1
print(a)
1:已知字符串 str= 'skdaskerkjsalkj',请统计该字符串中各字母出现的次数
思路是:用字典
str='skdaskerkjsalkj'标签:python,编程,skdaskerkjsalkj,面试,str,字符串 From: https://www.cnblogs.com/vip01/p/16745814.html
a=dict()
for i in str:
if i not in a.keys():
a[i]=1
else:
a[i]=a[i]+1
print(a)