使用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")

相关文章:

  • 2022-12-23
  • 2021-04-19
  • 2022-01-07
  • 2022-12-23
  • 2021-12-19
  • 2021-06-26
  • 2021-11-11
猜你喜欢
  • 2022-12-23
  • 2022-03-06
  • 2021-06-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案