SyntaxFix
Write A Post
Hire A Developer
Questions
Try writing it in a new file..
f = open(filename, 'r+') f2= open(filename2,'a+') text = f.read() text = re.sub('foobar', 'bar', text) f.seek(0) f.close() f2.write(text) fw.close()