2026年8月16日 20時49分

大文字・小文字

最終更新:2026年8月16日 20時52分

大文字にしたければ、upper()

小文字にしたければ、lower()

大文字と小文字を反転させたければ、swapcase()

使用例

text = "Hello World"

という文字列がある

大文字にする

print(text.upper())

HELLO WORLD

小文字にする

print(text.lower())

hello world

大文字と小文字を入れ替える

print(text.swapcase())

hELLO wORLD

ソースコード

大文字・小文字 · ki-hi-ro/python@2711b02

カテゴリー:技術・開発

タグ: