istitle() 方法是檢查不可大小字母的字串中的所有基於大小寫字元是否可大寫,所有其他基於大小寫字元都是小寫。
語法
以下為 istitle() 方法的語法:
str.istitle()
參數
-
NA
返回值
如果字串是標題字串,並且至少有一個字元,此方法返回 true,例如:大寫字元可能只能跟著不可大小字元和小寫字元只轉換一次。否則返回false。
示例
下麵的示例說明 istitle() 方法的使用。
#!/usr/bin/python3 str = "This Is String Example...Wow!!!" print (str.istitle()) str = "This is string example....wow!!!" print (str.istitle())
當我們運行上面的程式,會產生以下結果 -
True False