isnumeric

概要Description

签名

s.isnumeric(): bool

功能

判断并返回 这个字符串 是不是都是数字

支持 Unicode 数字含义 和 数值含义 的字符

广告

案例Examples

正常情况

都是数字
1 2 =
s = '9917'result = s.isnumeric()True
有一个不是数字
1 2 =
s = ':9917'result = s.isnumeric()False

其它情况

掺杂空格不行
1 2 =
s = ' 9917'result = s.isnumeric()False
没有数字也不行
1 2 =
s = ''result = s.isnumeric()False

支持 Unicode 数字含义 的 字符

Unicode 中 有些有数字含义的字符

比如

¹
₁
①
⒈

这些字符,会被检测通过

1 =
'⁹₉¹₇'.isnumeric()True

支持 Unicode 数值含义 的 字符

Unicode 中 有些有数值含义的字符

比如

½

这些字符,会被检测通过

1 =
'½'.isnumeric()True
广告

ZZAX 微信公众

文档一更新,立刻告诉你