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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM