字符串中查找字母有几个

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('')
    

 

posted @ 2016-07-21 20:23  疯陈演义  阅读(294)  评论(0编辑  收藏  举报