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

查看所有标签

Head First jQuery

Head First jQuery

Ryan Benedetti , Ronan Cranley / O'Reilly Media / 2011-9 / USD 39.99

Want to add more interactivity and polish to your websites? Discover how jQuery can help you build complex scripting functionality in just a few lines of code. With Head First jQuery, you'll quickly g......一起来看看 《Head First jQuery》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具