题解 | #在字符串中找出连续最长的数字串#
在字符串中找出连续最长的数字串
https://www.nowcoder.com/practice/2c81f88ecd5a4cc395b5308a99afbbec
import re while True: try: s = input() pat = r"\d+" digi_parts = re.findall(pat, s) digi_parts.sort(key=len, reverse=True) max_l = len(digi_parts[0]) for digi_part in digi_parts: if len(digi_part) < max_l: break else: print(f"{digi_part}", end="") print(f",{max_l}") except: break