Skip to content

Instantly share code, notes, and snippets.

@mperlet
Created April 26, 2016 13:08
Show Gist options
  • Save mperlet/fb00d7a19da816b3412b9c2a0e8ea975 to your computer and use it in GitHub Desktop.
Save mperlet/fb00d7a19da816b3412b9c2a0e8ea975 to your computer and use it in GitHub Desktop.
Replace $$key$$ with value in file test.txt with: *python simple_template.py test.txt key=value*
import sys
content = open(sys.argv[1], 'r').read()
for k,v in map(lambda kv:kv.split("="),sys.argv[2:]):
content = content.replace('$$%s$$' % k, '%s' % v)
print(content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment