Latest web development tutorials

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