文字列の一部分を別の文字列で置き換える。
[実験]
>>> s = 'This is an apple.'
>>> s.replace('apple', 'orange')
'This is an orange.'
>>> s
'This is an apple' ← 変数sの値は変わらない
Pythonプログラミングの備忘録
文字列の一部分を別の文字列で置き換える。
[実験]
>>> s = 'This is an apple.'
>>> s.replace('apple', 'orange')
'This is an orange.'
>>> s
'This is an apple' ← 変数sの値は変わらない