Python中的 isdigit()方法

Python isdigit()方法

sdigit()方法就是检测字符串是否只有数字组成,


如果字符串中是只有数字组成,则返回true,

如果字符串中有其他字符,则返回false。

语法格式是:  str.isdigit()

#!/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/xuchunlin/p/5534439.html