题解 | #在字符串中找出连续最长的数字串#
在字符串中找出连续最长的数字串
https://www.nowcoder.com/practice/2c81f88ecd5a4cc395b5308a99afbbec
最扯蛋的python3
def func(s): t = 0 res = [] dic = {} lst = [str(i) for i in range(10)] i = 0 while i < len(s): if s[i] in lst: tmp = s[i] for j in range(i+1,len(s)+1): if s[j] in lst: tmp += s[j] else: i = j break dic[str(tmp)] = len(tmp) else: i +=1 for i in dic.values(): if i >= t: t = i for i in dic.keys(): if dic[i] == t: print(i,end = '') print(f',{t}') while True: try: s= input() s = s+'e' func(s) except: break