当前位置: 首页 > 文档资料 > Python 中文教程 >

istitle()

优质
小牛编辑
133浏览
2023-12-01

描述 (Description)

方法istitle()检查非基于案例的字母后面的字符串中的所有基于案例的字符是否为大写,所有其他基于案例的字符是否为小写。

语法 (Syntax)

以下是istitle()方法的语法 -

str.istitle()

参数 (Parameters)

  • NA

返回值 (Return Value)

如果字符串是一个带有标题的字符串并且至少有一个字符,则此方法返回true,例如,大写字符可能只跟随无法使用的字符,而小写字符只能使用套接字符。否则返回false。

例子 (Example)

以下示例显示了istitle()方法的用法。

#!/usr/bin/python
str = "This Is String Example...Wow!!!";
print str.istitle()
str = "This is string example....wow!!!";
print str.istitle()

当我们运行上面的程序时,它产生以下结果 -

True
False