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

 


 
                    
            
                

相关文章:

  • 2022-12-23
  • 2021-12-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-26
  • 2021-12-13
  • 2022-12-23
  • 2022-01-14
  • 2022-12-23
  • 2021-06-24
相关资源
相似解决方案