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())
自己動手試一試 »