python中title函数的作用
宋雪维
2021-02-20 09:21:0819926浏览 · 0收藏 · 0评论
本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。
1、title函数
python中字符串函数,返回’标题化‘的字符串,就是单词的开头为大写,其余为小写
2、语法
string.title()
3、使用实例
str=' tHe wOrLDwidE Web ' str.title() str.title().strip()
输出
' The Worldwide Web ' 'The Worldwide Web'
以上就是python中title函数的介绍,大家如果需要将字符串转换为标题格式,可以使用title函数哦~
关注公众号,随时随地在线学习