无涯教程-Python - isspace()函数

58 阅读1分钟

Python isspace()检查字符串是否包含空格。

isspace() - 语法

str.isspace()

isspace() - 返回值

如果字符串中只有空格字符并且至少有一个字符,则此方法返回true,否则返回false。

isspace() - 示例

以下示例显示isspace()方法的用法。

#!/usr/bin/python

str=" "; print str.isspace()

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

当无涯教程运行上面的程序时,它产生以下输出-

True
False

参考链接

www.learnfk.com/python/stri…