小白教程
所有教程
关于
Search
172.71.254.95
172.71.254.95
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Python3 string title”的源代码
本页内容
上一节:
Python3_string_swapcase
下一节:
Python3_string_translate
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:title()}}[[Category:python3 string|36]] = Python3 title()方法 = [[python3 string|Python3 字符串]] == 描述 == Python title() 方法返回"标题化"的字符串,就是说所有单词的首个字母转化为大写,其余字母均为小写(见 [[python3 string istitle|istitle()]])。 == 语法 == title()方法语法: <sample title="" desc="" lang="python" hererun="1"> str.title(); </sample> == 参数 == * NA。 == 返回值 == 返回"标题化"的字符串,就是说所有单词的首字母都转化为大写。 以下实例展示了 title()函数的使用方法: == 实例(Python 3.0+) == <sample title="" desc="" lang="python" hererun="1"> #!/usr/bin/python3 str = "this is string example from xiaobai....wow!!!" print (str.title()) </sample> 以上实例输出结果如下: <sample title="" desc="" lang="python" hererun="1"> This Is String Example From xiaoBai....Wow!!! </sample> 请注意,非字母后的第一个字母将转换为大写字母: == 实例(Python 3.0+) == <sample title="" desc="" lang="python" hererun="1"> #!/usr/bin/python3 txt = "hello b2b2b2 and 3g3g3g" x = txt.title() print(x) </sample> 输出结果为: <sample title="" desc="" lang="python" hererun="1"> Hello B2B2B2 And 3G3G3G </sample> [[python3 string|Python3 字符串]]
返回至“
Python3 string title
”。
上一节:
Python3_string_swapcase
下一节:
Python3_string_translate