Python_字符串次数统计

a = 'kdjflsjdflsnc,nkdooooooo'

print(a.count('o')

//自己傻了,哈哈

>>> count = 0
>>> word = "dkfjlskdjfaaaaa"
>>> for letter in word:
if letter == "a":
count = count + 1

 

posted @ 2018-03-20 14:52  solitude_26  阅读(131)  评论(0编辑  收藏  举报