python题解,
在字符串中找出连续最长的数字串
http://www.nowcoder.com/questionTerminal/2c81f88ecd5a4cc395b5308a99afbbec
while True: try: s = input() res = '' max_length = 0 i = 0 while i < len(s): start = i while i < len(s) and s[i].isdigit(): i += 1 if i - start > max_length: #当前长度大于此前求出的最长长度,修改长度和子串 max_length = i - start res = s[start:i] elif i - start == max_length and max_length > 0: #当前长度等于此前求出的最长长度,在已有子串结果后加上当前得到的子串 res += s[start:i] i += 1 print(res, max_length, sep = ',') except: break