python函数--isdigit()方法

isdigit()方法

描述:Python isdigit() 方法检测字符串是否只由数字组成。isdigit()方法语法:str.isdigit()参数:无。返回值:如果字符串只包含数字则返回 True 否则返回 False。

复制代码
复制代码
In [6]:'123'.isdigit()
Out[6]:True
In [7]:'aa234'.isdigit()
Out[7]:False
In [8]:'①②③'.isdigit()
Out[8]:True
In [10]:"中文".isdigit()
Out[10]:False
In [11]:'12+6'.isdigit()
Out[11]:False
复制代码
复制代码
原文地址:https://www.cnblogs.com/hanjiali/p/11589565.html