How to check whether a string consists of letters in python: string.isalpha()

Y2J
Release: 2017-05-18 15:08:15
Original
3205 people have browsed it

python string.isalpha() method

python string isalpha() method checks whether a string consists of only alphabetic characters.

Syntax:

str.isalpha()
Copy after login

Parameters:
The following are detailed parameters:
Not applicable
Return value :
It returns true if all characters in the string are letters and there is at least one character, otherwise it returns false.
For example:

#!/usr/bin/python
str = "this";  # No space & digit in this string
print str.isalpha();
str = "this is string example....wow!!!";
print str.isalpha();
Copy after login

This will output the following results:

True
False
Copy after login

[Related recommendations]

1. Python Free Video Tutorial

2. isalpha in Python 2.7 does not support unicode

The above is the detailed content of How to check whether a string consists of letters in python: string.isalpha(). For more information, please follow other related articles on the PHP Chinese website!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!