Python 字符串 istitle() 方法
定義和用法
如果文本中的所有單詞均以大寫字母開頭,而單詞的其余部分均為小寫字母,則 istitle() 方法返回 True。否則返回 False。
符號和數字將被忽略。
語法
string.istitle()
參數值
無參數.
更多實例
實例
檢查每個單詞是否以大寫字母開頭:
a = "HELLO, AND WELCOME TO MY WORLD" b = "Hello" c = "22 Names" d = "This Is %'!?" print(a.istitle()) print(b.istitle()) print(c.istitle()) print(d.istitle())