KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Currently I'm using this: f = open(filename, 'r+') text = f.read() text = re.sub('foobar', 'bar', text) f.seek(0) f.write(text) f.close() But the problem is that the old file is larger than the new file. So I end up with a new file that has a part of the old file on the end of it.
Tags (comma-separated)
Save Edits
Cancel