isdigit()方法

描述

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

语法

isdigit()方法语法:

str.isdigit()

参数

  • 无。

返回值

如果字符串只包含数字则返回 True 否则返回 False。

实例

以下实例展示了isdigit()方法的实例:

str = "123456"; 
print (str.isdigit())

str = "Runoob example....wow!!!"
print (str.isdigit())

# 结果为
# True
# False

 

相关文章:

  • 2022-12-23
  • 2021-08-19
  • 2021-07-05
  • 2021-06-24
  • 2021-12-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-26
  • 2021-12-13
  • 2022-12-23
  • 2021-08-19
  • 2022-12-23
  • 2022-01-14
相关资源
相似解决方案