python isdigit()

isdigit():

Python isdigit() 方法检测字符串是否只由数字组成。如果字符串只包含数字则返回 True 否则返回 False。

实例

以下实例展示了isdigit()方法的实例:

#!/usr/bin/python3

str = "123456"; 
print (str.isdigit())

str = "Runoob example....wow!!!"
print (str.isdigit())

以上实例输出结果如下:

True
False
原文地址:https://www.cnblogs.com/JackFang-X/p/11089967.html