String 字元/Case 調整大小寫

  • Python 調整英文字母的大小寫:
    • .upper() :全數變成大寫
    • .lower() :全數變成小寫
    • .title() :單字字首大寫
    • .capitalize() :字首變成大寫
    • .swapcase() :大小寫轉換
shaq = "Shaquille O'Neal"
print(shaq.upper())
## SHAQUILLE O'NEAL

print(shaq.lower())
## shaquille o'neal

print(shaq.lower().title())
## Shaquille O'Neal

print(shaq.capitalize())
## Shaquille o'neal

print(shaq.swapcase())
## sHAQUILLE o'nEAL

Reference:

results matching ""

    No results matching ""