Python3 string.isspace()方法

isspace() 方法检查字符串是否包含空格

语法

以下是 isspace()方法的语法:
str.isspace()

参数

  • NA

返回值

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

示例

下面的示例显示 isspace()方法的使用。
#!/usr/bin/python3

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

str = "This is string example....wow!!!"
print (str.isspace())
当我们运行上面的程序,会产生以下结果 -
True
False

上一篇: Python3数字 下一篇: Python3字符串