小白教程
所有教程
关于
Search
172.69.59.25
172.69.59.25
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Python3 string isnumeric”的源代码
本页内容
上一节:
Python3_string_islower
下一节:
Python3_string_isspace
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:isnumeric()}}[[Category:python3 string|14]] = Python3 isnumeric()方法 = [[python3 string|Python3 字符串]] == 描述 == isnumeric() 方法检测字符串是否只由数字组成,数字可以是: Unicode 数字,全角数字(双字节),罗马数字,汉字数字。 指数类似 ² 与分数类似 ½ 也属于数字。 <sample title="" desc="" lang="python" hererun="1"> # s = '½' s = '\u00BD' </sample> == 语法 == isnumeric()方法语法: <sample title="" desc="" lang="python" hererun="1"> str.isnumeric() </sample> == 参数 == * 无。 == 返回值 == 如果字符串中只包含数字字符,则返回 True,否则返回 False 以下实例展示了 isnumeric() 方法的实例: <sample title="" desc="" lang="python" hererun="1"> #!/usr/bin/python3 str = "xiaobai2016" print (str.isnumeric()) str = "23443434" print (str.isnumeric()) </sample> 以上实例输出结果如下: <sample title="" desc="" lang="python" hererun="1"> False True </sample> Unicode 数字: <sample title="" desc="" lang="python" hererun="1"> #!/usr/bin/python3 #s = '²3455' s = '\u00B23455' print(s.isnumeric()) # s = '½' s = '\u00BD' print(s.isnumeric()) a = "\u0030" #unicode for 0 print(a.isnumeric()) b = "\u00B2" #unicode for ² print(b.isnumeric()) c = "10km2" print(c.isnumeric()) </sample> 以上实例输出结果如下: <sample title="" desc="" lang="python" hererun="1"> True True True True False </sample> [[python3 string|Python3 字符串]]
返回至“
Python3 string isnumeric
”。
上一节:
Python3_string_islower
下一节:
Python3_string_isspace