python检测字符串是否只由数字组成

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


In [5]: str = "123456";  # Only digit in this string

In [6]: print str.isdigit();

True


In [7]: 

In [7]: str = "this is string example....wow!!!";

In [8]: print str.isdigit();

False


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章