【LeetCode】1668.最大重复子字符串(三)
作者:互联网
4、使用count()方法
Python count() 方法用于统计字符串里某个字符或子字符串出现的次数。可选参数为在字符串搜索的开始与结束位置。
>>> str='aaabaaaabaaabaaaabaaaabaaaabaaaaba'
>>> substr='aaaba'
>>> str.count(substr)
6
>>> str.count('12')
0
>>>
count()语法:
str.count(sub, start= 0,end=len(string))
标签:count,aaabaaaabaaabaaaabaaaabaaaabaaaaba,重复子,或子,substr,str,1668,字符串,LeetCode 来源: https://www.cnblogs.com/LeeCookies/p/15763717.html