python 字符串方法isdigit()

python isdigit() 方法检测字符串是否只有数字组成。

语法:

isdigit()方法语法:

str.isdigit()

参数:

返回值:

如果字符串中只含有数字则返回True,否则返回False。

实例:

#!/usr/bin/python

str = "123456";  # Only digit in this string
print str.isdigit();

str = "this is string example....wow!!!";
print str.isdigit();

以上实例输出结果:

True
False
 
原文地址:https://www.cnblogs.com/lxwphp/p/15454271.html