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://www.codercto.com/courses/l/10.html

查看所有标签

Release It!

Release It!

Michael T. Nygard / Pragmatic Bookshelf / 2007-03-30 / USD 34.95

“Feature complete” is not the same as “production ready.” Whether it’s in Java, .NET, or Ruby on Rails, getting your application ready to ship is only half the battle. Did you design your system to......一起来看看 《Release It!》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具