Python3 isspace()方法
描述
Python isspace() 方法檢測(cè)字符串是否只由空格組成。
語(yǔ)法
isspace()方法語(yǔ)法:
str.isspace()
參數(shù)
- 無(wú)。
返回值
如果字符串中只包含空格,則返回 True,否則返回 False.
實(shí)例
以下實(shí)例展示了isspace()方法的實(shí)例:
#!/usr/bin/python3
str = " "
print (str.isspace())
str = "W3CSchool example....wow!!!"
print (str.isspace())
以上實(shí)例輸出結(jié)果如下:
True
False
更多建議: