Python isspace() Method

Python 字符串Python String


Description

The Python isspace() method checks whether the string consists only of spaces.

Syntax

The syntax of the isspace() method is:

str.isspace()

Parameters

  • None.

Return Value

Returns True if the string contains only spaces; otherwise, returns False.

Example

The following example demonstrates the use of the isspace() method:

#!/usr/bin/python

str = "       "; 
print str.isspace();

str = "This is string example....wow!!!";
print str.isspace();

The output of the above example is:

True
False

Python 字符串Python String

Other Extensions