使用str.isdigit();有两种使用方法

str.isdigit('12345') =====>True

str.isdigit('aaaaa')======>False

或者

'12345'.isdigit()=======>True

'aaaaa'.isdigit()=======>False

注意

1.使用的是str,而不是string

2.不能判断负数符

  str.isdigit('-12345')====>False

把字符串转换为数字:

  int("12345")

posted on 2015-12-23 15:42  Mr.He多多指教  阅读(3176)  评论(0编辑  收藏  举报