python中的 upper() lower()capitalize()title()方法
Posted littlefive
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python中的 upper() lower()capitalize()title()方法相关的知识,希望对你有一定的参考价值。
upper()字符串中字母由小写变为大写
lower()字符串中字母由大写变为小写
capitalize()字符串中字母首字母大写其余小写
title()字符串中字母每个单词的首字母大写其余小写
1 a = "hello"
2 b = "WORLD"
3 c = "hello"
4 d = "hello world"
5 a1 = a.upper()
6 b1 = b.lower()
7 c1 = c.capitalize()
8 d1 = d.title()
9 print(a1)
10 print(b1)
11 print(c1)
12 print(d1)
复制代码
输出结果:
HELLO
world
Hello
Hello World
以上是关于python中的 upper() lower()capitalize()title()方法的主要内容,如果未能解决你的问题,请参考以下文章
Python 字符串title()upper()lower()方法
python中的upperlowercapitalizetitle
python3----转换大小写(upper lower capitalize and title)