题解 | #在字符串中找出连续最长的数字串#
在字符串中找出连续最长的数字串
https://www.nowcoder.com/practice/2c81f88ecd5a4cc395b5308a99afbbec
while True:
try:
s = input()
childs = ""
for c in s:
if ord("0") <= ord(c) <= ord("9"):
childs += c
else:
childs += " "
childs_lst = []
max_len = 0
for i in list(childs.strip().split()):
if max_len < len(str(i)):
max_len = len(str(i))
childs_lst.clear()
childs_lst.append(i)
elif max_len == len(str(i)):
childs_lst.append(i)
# print(childs_lst, max_len)
print("".join(str(x) for x in childs_lst), max_len, sep=",")
except:
break
