Python istitle()方法

Python 字串 Python 字串


描述

Python istitle() 方法檢測字串中所有的單詞拼寫首字母是否為大寫,且其他字母為小寫。

語法

istitle()方法語法:

str.istitle()

參數

  • 無。

返回值

如果字串中所有的單詞拼寫首字母是否為大寫,且其他字母為小寫則返回 True,否則返回 False.

實例

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

#!/usr/bin/python


str = "This Is String Example...Wow!!!";
print str.istitle();

str = "This is string example....wow!!!";
print str.istitle();

以上實例輸出結果如下:

True
False

Python 字串 Python 字串