python中title函数的作用

本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。

1、title函数

python中字符串函数,返回’标题化‘的字符串,就是单词的开头为大写,其余为小写

2、语法

string.title()

3、使用实例

str='tHewOrLDwidEWeb'
str.title()
str.title().strip()

输出

'TheWorldwideWeb'
'TheWorldwideWeb'