Python大小写转换

大写

把所有字符中的小写字母转换成大写字母

>>> str = "hELLO wOrld!"
>>> print (str.upper())
HELLO WORLD!

小写

把所有字符中的大写字母转换成小写字母

>>> str = "hELLO wOrld!"
>>> print (str.lower())
hello world!

第一个字母转为大写

把第一个字母转化为大写字母,其余小写

>>> str = "hELLO wOrld!"
>>> print (str.capitalize())
Hello world!

每个单词的第一个字母大写

把每个单词的第一个字母转化为大写,其余小写

>>> str = "hELLO wOrld!"
>>> print (str.title())
Hello World!
上一篇 Python遍历字典dict的几种方法
下一篇 Python中的类变量、成员变量、静态方法、成员方法
目录
文章列表
1 支付宝离线支付原理
支付宝离线支付原理
2
Groovy代码示例 - 文件操作
Groovy代码示例 - 文件操作
3
MyBatis之java.lang.UnsupportedOperationException异常解决方案
MyBatis之java.lang.UnsupportedOperationException异常解决方案
4
Android自定义广播设置只能由指定的APP接收
Android自定义广播设置只能由指定的APP接收
5
Spring Cloud Gray接入及部署采坑记录
Spring Cloud Gray接入及部署采坑记录
最新评论
一位WordPress评论者
一位WordPress评论者
2月12日
您好,这是一条评论。若需要审核、编辑或删除评论,请访问仪表盘的评论界面。评论者头像来自 Gravatar。