字符串方法title()、istitle()

title()、istitle()

语义解释:

title() 方法返回"标题化"的字符串,就是说所有单词的首个字母转化为大写,其余字母均为小写。

istitle() 方法检测字符串中所有的单词拼写首字母是否为大写,且其他字母为小写。

实际运用:

1 a=b='hello  world!'
2 print(a.title())
3 print(a.title().istitle())
4 print(b.istitle())

Hello World!
True
False

猜你喜欢

转载自www.cnblogs.com/zc13/p/9486290.html