题解 | #在字符串中找出连续最长的数字串#
在字符串中找出连续最长的数字串
https://www.nowcoder.com/practice/2c81f88ecd5a4cc395b5308a99afbbec
import re while True: try: strings = input() numbers_list = re.findall('\d+', strings) max_len = len(sorted(numbers_list, key=lambda x: len(x), reverse=True)[0]) result_list = [] for i in numbers_list: if len(i) == max_len: result_list.append(i) result = ''.join(result_list) print(result + ',' + str(max_len)) except: break