Python String - isdecimal() Method
The Python isdecimal() method is used to check whether all characters of the string are decimal or not. It returns true when all characters of the string are decimal, else returns false. Decimal characters belongs to numbers 0 - 9.
Syntax
string.isdecimal()
Return Value
Returns True if all characters of the specified string are decimal, else returns False.
Example:
In the example below, isdecimal() method is used to check whether all characters of the string are decimal or not.
MyString = "12345" print(MyString.isdecimal())
The output of the above code will be:
True
Example:
In the example below, isdecimal() method is used to check whether all characters of the unicode string object are decimal or not.
MyString = "\u0035" #unicode for 5 print(MyString.isdecimal())
The above code will give the following output:
True
Recommended Pages
❮ Python String Methods