python提供了专门函数可用:
str.count(string,start_index,end_index)
sting:查找的字符
start_index:开始查找的位置,缺省时则从头开始
end_index:结束查找的位置,缺省时则查找到字符串最末
示例:
>>> count = str.count('jj',2,len(str))
>>> str = 'djjoojjllojj99jj8'
>>> count = str.count('jj')
>>> print(count)
4
>>> count = str.count('jj',2,len(str))
>>> print(count)
3