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

字符串中查找字母有几个

时间:2016-07-21 21:37:28      阅读:94      评论:0      收藏:0      [点我收藏+]

标签:

p = 0
s = ‘How can i get there?‘
for i in s:
    
    if i == ‘P‘or i == ‘p‘:
        p = p + 1 
    else:
        continue
    
if p != 0:
    print(‘有‘,p,‘个‘)
else:
    print(‘无‘)
    

 

字符串中查找字母有几个

标签:

原文地址:http://www.cnblogs.com/wumac/p/5693046.html

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