打印字符串里每个字符的个数

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