Python 3 – isdecimal() Method
Python 3 – isdecimal() Method
Description
isdecimal() method checks whether a string contains only decimal characters. This method only exists on Unicode objects.
Note − Unlike Python 2, all strings are represented as Unicode in Python 3. The following is an example.
Syntax
The following is the syntax for the isdecimal() method:
str.isdecimal()
Parameters
NA
Return Value
Returns true if all characters in the string are decimal, otherwise returns false.
Example
The following example shows the use of the isdecimal() method.
#!/usr/bin/python3
str = "this2016"
print (str.isdecimal())
str = "23443434"
print (str.isdecimal())
Result
When running the above program, it produces the following result:
False
True