找出最长连续子串

def func(s: str):
temp = ''
count = 0
for i in range(len(s)):
for j in range(i + 1, len(s)):
if s[i] != s[j]:
break
j += 1
if count < j - i:
count = j - i
temp = s[i:j]
i = j
return temp, count


if __name__ == '__main__':
print(func('adsgggggsdfssssssseeeee'))
posted @ 2022-05-30 21:52  狒狒桑  阅读(18)  评论(0编辑  收藏  举报