统计字符串中各个字符的个数
def histpgram(s):
d=dict()
for c in s:
if c not in d:
d[c]=1
else:
d[c]+=1
return d
string='jdkfjkfhdlkfhgkhklfdhfheifhedskjhflksdhdhfdhfdshfhdhfs'
print histpgram(string)
统计字符串中各个字符的个数
def histpgram(s):
d=dict()
for c in s:
if c not in d:
d[c]=1
else:
d[c]+=1
return d
string='jdkfjkfhdlkfhgkhklfdhfheifhedskjhflksdhdhfdhfdshfhdhfs'
print histpgram(string)

被折叠的 条评论
为什么被折叠?