I have a file and I want to change a particular string in the file. Here is what I am trying
import re
with open ('input.txt', 'rw' ) as f:
content = f.read()
content_new = re.sub('destination', r'TEST', content, flags = re.M)
But this is not actually doing anything or updating the file. i.e I am not seeing the destination
updated to TEST
. Can someone help me and tell me what I am doing wrong?
Is it that I am not writing to file? or ??