Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python isdecimal() method

Python isdecimal() method

Python Strings Python Strings


Description

The Python isdecimal() method checks whether a string contains only decimal characters. This method only exists on unicode objects.

**Note:** To define a decimal string, simply add the 'u' prefix before the string.

Syntax

isdecimal() method syntax:



str.isdecimal()

Parameters

Return Value

Returns True if the string contains only decimal characters, otherwise returns False.

Example

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



#!/usr/bin/python





str = u"this2009";  

print str.isdecimal();



str = u"23443434";

print str.isdecimal();

The output of the above example is:



False

True


Python Strings Python Strings