这篇教程Python isdigit()方法写得很实用,希望能帮到您。 描述Python isdigit() 方法检测字符串是否只由数字组成。 语法isdigit()方法语法: str.isdigit() 参数返回值如果字符串只包含数字则返回 True 否则返回 False。 实例以下实例展示了isdigit()方法的实例: #!/usr/bin/pythonstr = "123456"; # Only digit in this stringprint str.isdigit();str = "this is string example....wow!!!";print str.isdigit(); 以上实例输出结果如下: TrueFalse Python isdecimal()方法 Python islower()方法 |