import sys import re phone=input() print(re.sub('\D','',phone)) # 第一个参数是非数字与'\d'相反(匹配模式pattern),第二个是要替换的字符,第三个是输入的字符