题解 | #在字符串中找出连续最长的数字串# 简单易懂
在字符串中找出连续最长的数字串
https://www.nowcoder.com/practice/2c81f88ecd5a4cc395b5308a99afbbec
while True:
try:
st=input()+" " # 加一位非数字,则不需要注释的那段代码
s=""
l=[]
max_l=0
for ii,i in enumerate(st):
if i.isdigit():
s+=i
# if ii==len(st)-1 :# 如果数字是最后一位
# if len(s)==max_l:
# l.append(s)
# elif len(s)>max_l:
# l=[s]
# max_l=len(s)
else:
if s!="" and len(s)==max_l:
l.append(s)
elif len(s)>max_l:
max_l=len(s)
l=[s]
s=""
print("".join(l)+","+str(max_l))
except:
break

