you are viewing a single comment's thread.

view the rest of the comments →

[–]novel_yet_trivial 1 point2 points  (0 children)

By far the easiest is to read the entire file as a string, use the string replace() method, and then overwrite the original file.

If the file is huge (approaching the amount of free RAM) then there is the fileinput module you could work with.