Python3 isdecimal()方法

Python 3 教程 · 2019-02-06 10:58:45

描述

isdecimal() 方法检查字符串是否只包含十进制字符。这种方法只存在于unicode对象。

注意:定义一个十进制字符串,只需要在字符串前添加 'u' 前缀即可。

语法

isdecimal()方法语法:

str.isdecimal()

参数

返回值

如果字符串是否只包含十进制字符返回True,否则返回False。

实例

以下实例展示了 isdecimal()函数的使用方法:

#!/usr/bin/python3

str = "codercto2016"
print (str.isdecimal())

str = "23443434"
print (str.isdecimal())

以上实例输出结果如下:

False
True

点击查看所有 Python 3 教程 文章: https://codercto.com/courses/l/10.html

查看所有标签

最优化导论

最优化导论

桑达拉姆 / 人民邮电出版社 / 2008-4 / 59.00元

最优化导论(英文版),ISBN:9787115176073,作者:(美国)(Sundaram、R、K)桑达拉姆一起来看看 《最优化导论》 这本书的介绍吧!

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

html转js在线工具
html转js在线工具

html转js在线工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试