re.sub を使用して文字列内の 2 つの単語を他の 2 つの単語に変更すると、出力が得られました。しかし、数値出力でそれを試してみると、正しく出力されません
>>> import re
>>> a='this is the string i want to change'
>>> re.sub('(.*)is(.*)want(.*)','\\1%s\\2%s\\3' %('was','wanted'),a)
'this was the string i wanted to change'
>>> re.sub('(.*)is(.*)want(.*)','\\1%s\\2%s\\3' %('was','12345'),a)
'this was\x8a345 to change'
>>>
なぜこれが起こるのかわかりません。これを使用する方法を教えてください。事前に感謝します