文字列置換 replace関数

文字列の一部分を別の文字列で置き換える。

[実験]

>>> s = 'This is an apple.'
>>> s.replace('apple', 'orange')
'This is an orange.'
>>> s
'This is an apple' ← 変数sの値は変わらない