Day 33stripとreplaceで文字列整形

2026-03-29 JST ・ 難易度: 入門 ・ カテゴリ: 文字列

Pythonコード

1text = '   Hello, World!   '2print(text)3print(text.strip())4new_text = text.replace('World', 'Python')5print(new_text)

解説

次に試してみよう