Python - String isdecimal() Method


Advertisements

The string 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()

Example:

In the below example, isdecimal() method to used to check whether all characters of the string are decimal or not.

MyString = "12345"
print(MyString.isdecimal())

Output

True 

Example:

In the below example, isdecimal() method to used to check whether all characters of the unicode string object are decimal or not.

MyString = "\u0035"        #unicode for 5
print(MyString.isdecimal())

Output

True  





String Methods
Advertisements