Home > Backend Development > Python Tutorial > Use of the isdecimal() method to process strings in Python

Use of the isdecimal() method to process strings in Python

高洛峰
Release: 2017-01-09 11:40:31
Original
2397 people have browsed it

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()
Copy after login

##Parameters

NA

Return value

This method returns true if all characters in the string are decimal, otherwise it returns false.

Example

The following example shows the use of isdecimal() method.

#!/usr/bin/python
 
 
str = u"this2009";
print str.isdecimal();
 
str = u"23443434";
print str.isdecimal();
Copy after login

When we run the above program, it will produce the following results:

False
True
Copy after login
More isdecimal( ) method, please pay attention to the PHP Chinese website for related articles!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template