import re
def find(s):
max = 0
count = 0
end = 0
if bool(re.search(r'\d', s))==False:
print('No')
else:
for i in range(len(s)):
if (s[i] >= '0' and s[i] <= '9'):
count += 1
if (max < count):
max = count
end = i
else:
count = 0
print(s[end - max + 1:end + 1])
s = str(input())
find(s)
python 查找字符串中最长的数字子串 PTA
最新推荐文章于 2024-06-12 15:22:07 发布