Python3 isspace()方法

Python3 字串 Python3 字串


描述

Python isspace() 方法檢測字串是否只由空白字元組成。

語法

isspace() 方法語法:

str.isspace()

參數

  • 無。

返回值

如果字串中只包含空格,則返回 True,否則返回 False.

實例

以下實例展示了isspace()方法的實例:

實例

#!/usr/bin/python3 str = " " print (str.isspace()) str = "zaixian example....wow!!!" print (str.isspace())

以上實例輸出結果如下:

True
False

Python3 字串 Python3 字串