python identificare random syntax in text -


i have input text file bio.txt

enter chance {win|earn|gain|obtain|succeed|acquire|get}  1⃣click {link|url|link up|site|web link} below️ 2⃣enter name 3⃣do submit(inside optin {put|have|positioned|set|placed|apply|insert|locate|situate|put|save|stick|know|keep} {shipping|delivery|shipment} adress) 

need locate syntax {win|earn|gain|obtain|succeed|acquire|get} , return random word, example : win

how can locate in python started code :

input = open('bio.txt', 'r').read() 

first, need read text file string; find pattern "{([a-z|]+)}" using regex, split them "|" make list random words. achieved following:

import re, random seed = [] matches = re.findall('{([a-z|]+)}', open('bio.txt', 'r').read()) [seed.extend(i.split('|')) in matches] input = random.choice(seed) 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -