码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2018-05-08 19:18:42      阅读:107      评论:0      收藏:0      [点我收藏+]

标签:append   hello   count   pytho   end   print   int   class   []   

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)

  

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

标签:append   hello   count   pytho   end   print   int   class   []   

原文地址:https://www.cnblogs.com/wf-skylark/p/9009663.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!