Python/ref string istitle
来自菜鸟教程
<languages />
Python字符串istitle()方法
例
检查每个单词是否以大写字母开头:
txt = "Hello, And Welcome To My World!" x = txt.istitle() print(x)
定义和用法
The
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())