摘要:
4、使用count()方法 Python count() 方法用于统计字符串里某个字符或子字符串出现的次数。可选参数为在字符串搜索的开始与结束位置。 >>> str='aaabaaaabaaabaaaabaaaabaaaabaaaaba' >>> substr='aaaba' >>> str.cou 阅读全文
posted @ 2022-01-04 19:20
MoKin_Li
阅读(51)
评论(0)
推荐(0)
摘要:
3、使用index()和rindex(): >>> str = "this is really a string example....wow!!!" >>> substr = "is" >>> print(str.index(substr)) 2 >>> print(str.rindex(subs 阅读全文
posted @ 2022-01-04 18:17
MoKin_Li
阅读(43)
评论(0)
推荐(0)
摘要:
考察的重点,是Python判断字符串是否包含另一字符串 class Solution: def maxRepeating(self, sequence: str, word: str) -> int: for _i in range(1,100): if word * _i in sequence: 阅读全文
posted @ 2022-01-04 18:12
MoKin_Li
阅读(60)
评论(0)
推荐(0)

浙公网安备 33010602011771号