用Python统计字符串中各字符的个数

摘要: #方式一:def count_str(s): adict = {} for x in str: if x not in adict: adict[x] = 1 else: adict[x] += 1 return adict #方式二:# def count_str02(s):# adict = { 阅读全文
posted @ 2021-09-16 14:41 tracker001 阅读(1865) 评论(0) 推荐(0)