次の行を含むテキスト ファイルがあります - a boy is drinking water
. このファイルを A.txt と呼ぶとします
私の目的は、単語water
をユーザーが A.txt に入力したものに置き換えることです。他のものをそのまま保持します。A.txt が変更されa boy is drinking juice
、A.txt がパラメーターとして Python スクリプトに渡された場合、出力をa boy is drinking juice
.
文字列内の特定の文字だけを置き換えるにはどうすればよいでしょうか。