Python isalpha() method

Python 字符串Python String


Description

The Python isalpha() method checks whether the string consists only of letters.

Syntax

Syntax of the isalpha() method:

str.isalpha()

Parameters

  • None.

Return Value

Returns True if the string has at least one character and all characters are letters; otherwise, returns False.

Example

The following example demonstrates the isalpha() method:

Example

#!/usr/bin/python
# coding=utf-8

str = "example";
print str.isalpha();

str = "example Rookie Tutorial";
print str.isalpha();

str = "this is string example....wow!!!";
print str.isalpha();

The output of the above example is:

True
False
False

Python 字符串Python String

Other Extensions