python - Grab elements inside parentheses -


how can grab elements inside parentheses , put them in file?

me (i) (you) him (he) (she)

thanks in advance, adia

import re  txt = 'me (i) (you) him (he) (she)' words = re.findall('\((.+?)\)', txt)  # words returns: ['i', 'you', 'he', 'she'] open('filename.txt', 'w') out:     out.write('\n'.join(words))  # file 'filename.txt' contains now:  

Comments

Popular posts from this blog

c++ - Compiling static TagLib 1.6.3 libraries for Windows -

PostgreSQL 9.x - pg_read_binary_file & inserting files into bytea -

asp.net - call stack missing info on mono with apache and mod_mono -