Python3 isdecimal() Method

Python3 字符串Python3 Strings


Description

The isdecimal() method checks whether the string contains only decimal characters.

Syntax

The syntax of the isdecimal() method is:

str.isdecimal()

Parameters

  • None

Return Value

  • True- If all characters in the string are decimal characters.
  • False- If at least one character is not a decimal character.

Example

The following example demonstrates how to use the isdecimal() function:

Example

#!/usr/bin/python3

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

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

The output of the above example is as follows:

False
True

Python3 字符串Python3 Strings

Other Extensions