Skip to content

Instantly share code, notes, and snippets.

@mghdotdev
Created June 5, 2015 16:31
Show Gist options
  • Save mghdotdev/11e0d559651add53aac7 to your computer and use it in GitHub Desktop.
Save mghdotdev/11e0d559651add53aac7 to your computer and use it in GitHub Desktop.
Python: File Read/Write
import re
def format_file(file1, file2):
output = re.sub(r'STUFF_TO_REPLACE', r'STUFF_TO_PUT_IN_PLACE', file1.read() )
file2.write(output)
format_file(open('input.txt', 'r'), open('output.txt', 'w'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment