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字串