给定一个字母数字字符串 S
,从该字符串中提取最大数值。所有字母均为小写。取最大连续位数作为一个数。
示例输入:23dsa43dsa98
预期输出:98
我试过:
import re
a=input()
item=([re.split(r'(\d+)', s) for s in (a)])
print(item)
最佳答案
这会起作用:
max(re.findall('\d+', a), key = lambda x: int(x))
关于python - 从给定字符串中提取最大数值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55480718/