题解 | #在字符串中找出连续最长的数字串#
在字符串中找出连续最长的数字串
http://www.nowcoder.com/practice/2c81f88ecd5a4cc395b5308a99afbbec
import re def func(string): a = re.sub('[a-zA-Z]',',',string) lst = [i for i in a.split(',') if i != ""] mi = 0 for i in range(1,len(lst)): if len(lst[i])>len(lst[mi]): mi = i for i in range(len(lst)): if len(lst[i])==len(lst[mi]): print(lst[i],end='') print(f',{len(lst[mi])}') while 1: try: string = input() func(string) except: break