import re x = input() print(re.sub(pattern=r"[^\d]", repl="",string = x))
re.sub(r"[^\d]+", "", x)
或
re.findall(r"\d+", x)