第三章 7-5 字符转换

s=input()
l=[]
for i in s:
    if i.isdigit():
       l.append(i) 
print(int(''.join(l)))
Python isdigit() 方法检测字符串是否只由数字组成

返回值:
如果字符串只包含数字则返回 True 否则返回 False。
发布了80 篇原创文章 · 获赞 6 · 访问量 7636

猜你喜欢

转载自blog.csdn.net/qq_33749437/article/details/104881448