题解 | #在字符串中找出连续最长的数字串#
在字符串中找出连续最长的数字串
http://www.nowcoder.com/practice/2c81f88ecd5a4cc395b5308a99afbbec
while True:
try:
sub_str = []
max_len = 0
str_input = input()
for i in range(len(str_input)):
for j in range(i + 1, len(str_input) + 1):
if str_input[i: j].isdecimal() and len(str_input[i: j]) >= max_len:
sub_str.append(str_input[i: j])
max_len = len(str_input[i: j])
result = ''
for each in sub_str:
if len(each) == max_len:
result += each
print(result + ',' + str(max_len))
except:
break