Latest web development tutorials

Python3 isalpha()方法

Python3 字符串 Python3字符串


描述

Python isalpha() 方法檢測字符串是否只由字母組成。

語法

isalpha()方法語法:

str.isalpha()

參數

  • 無。

返回值

如果字符串至少有一個字符並且所有字符都是字母則返回True,否則返回False

實例

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

#!/usr/bin/python3

str = "w3big"
print (str.isalpha())

str = "w3big example....wow!!!"
print (str.isalpha())

以上實例輸出結果如下:

True
False

Python3 字符串 Python3字符串