a = ‘hello world‘ b = [] for i in a: if ‘%s:%s‘ % (i, a.count(i)) not in b: b.append(‘%s:%s‘ % (i, a.count(i))) print(b)
打印字符串里每个字符的个数
原文:https://www.cnblogs.com/wf-skylark/p/9009663.html