统计句子“Life is short,we need Python.”中各字符出现的次数。
s='Life is short,we need Python.'
s=s.lower()
print(s)
dic={}
for a in s:
dic[a] = dic.get(a,0) + 1
for k in dic:
print(k,dic[k])
欢迎分享,转载请注明来源:内存溢出
统计句子“Life is short,we need Python.”中各字符出现的次数。
s='Life is short,we need Python.'
s=s.lower()
print(s)
dic={}
for a in s:
dic[a] = dic.get(a,0) + 1
for k in dic:
print(k,dic[k])
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)