首页 > 编程语言 > 详细

Python中的 isdigit()方法

时间:2016-05-27 14:35:35      阅读:191      评论:0      收藏:0      [点我收藏+]
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

 

Python中的 isdigit()方法

原文:http://www.cnblogs.com/xuchunlin/p/5534439.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!