Last active
January 14, 2016 11:01
-
-
Save mossbanay/b1c33f5bab29a5755823 to your computer and use it in GitHub Desktop.
Random spambot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import random | |
def random_keyword(match): | |
keywords = match.group(1).split('|') | |
return random.choice(keywords) | |
r = re.compile(r'{([^}]+)}') | |
with open('comment.txt') as f: | |
text = f.read() | |
output = re.sub(r, random_keyword, text) | |
print(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bonus extra readable version: