Python String isdecimal() Method Tutorial

In this section we will learn what String isdecimal() method is and how to use it in Python.

What is String isdecimal() Method in Python?

The Python string isdecimal() method is used to see if the target string value contains only decimal (0-9) values.

Note: this method will interpret the content of the string if necessary. For example, if the content of the string is in Unicode and the interpretation results in a decimal value, then this method will return the value True.

For example, the interpretation of the value “\u0033” is 3 and so this method returns the value True as a result.

Python String isdecimal() Method Syntax:

string.isdecimal()

String isdecimal() Method Parameter

The method does not take an argument.

String isdecimal() Method Return Value

The return value of this method is of type boolean and is equal to True if the target string value contains only decimal values. Otherwise the value False will return instead.

Example: using python string isdecimal() method

s1= "223434533"

s2 = "\u0033"

print(s1.isdecimal())

print(s2.isdecimal())

Output:

True

True
Facebook
Twitter
Pinterest
LinkedIn

Top Technologies