Latest web development tutorials

Python3 isdecimal()方法

Python3 字符串 Python3字符串


描述

isdecimal() 方法檢查字符串是否只包含十進製字符。 這種方法只存在於unicode對象。

注意:定義一個十進製字符串,只需要在字符串前添加'u'前綴即可。

語法

isdecimal()方法語法:

str.isdecimal()

參數

返回值

如果字符串是否只包含十進製字符返回True,否則返回False。

實例

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

#!/usr/bin/python3

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

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

以上實例輸出結果如下:

False
True

Python3 字符串 Python3字符串