Home > Article > Backend Development > Use of the isdecimal() method to process strings in Python
The isdecimal() method checks whether a string consists of decimal characters only. This method only exists for unicode objects.
Note: To define a string as Unicode, just prefix it with a 'u' left quote. Below are examples.
Syntax
The following is the syntax of the isdecimal() method:
str.isdecimal()
##Parameters NAReturn valueThis method returns true if all characters in the string are decimal, otherwise it returns false.
Example
#!/usr/bin/python str = u"this2009"; print str.isdecimal(); str = u"23443434"; print str.isdecimal();When we run the above program, it will produce the following results:
False TrueMore isdecimal( ) method, please pay attention to the PHP Chinese website for related articles!