Python3 title()方法
目录
描述
Python title() 方法返回”标题化”的字符串,就是说所有单词的首个字母转化为大写,其余字母均为小写(见 istitle())。
语法
title()
方法语法:
str.title();
参数
- NA。
返回值
返回”标题化”的字符串,就是说所有单词的首字母都转化为大写。
实例
以下实例展示了 title()
函数的使用方法:
#!/usr/bin/python3 str = "this is string example from mybj....wow!!!" print (str.title())
以上实例输出结果如下:
This Is String Example From Mybj....Wow!!!
请注意,非字母后的第一个字母将转换为大写字母:
#!/usr/bin/python3 txt = "hello b2b2b2 and 3g3g3g" x = txt.title() print(x)
输出结果为:
Hello B2B2B2 And 3G3G3G
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
码云笔记 » Python3 title()方法
码云笔记 » Python3 title()方法