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

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

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