题解 | #在字符串中找出连续最长的数字串#
在字符串中找出连续最长的数字串
https://www.nowcoder.com/practice/2c81f88ecd5a4cc395b5308a99afbbec
import sys
for line in sys.stdin:
a = line.strip()
just1 = False
numstr,tamp = [],''
for i in a:
if i.isdecimal():
tamp += i
elif tamp:
numstr.append([len(tamp),tamp])
tamp = ''
else:
if tamp:numstr.append([len(tamp),tamp])
num = max([i[0] for i in numstr])
for i in numstr:
if i[0] == num:
print(i[1],end="")
print(f',{num}')


阿里云工作强度 694人发布