Matching lines in Python -


i need match string in text file , want return matching line. let's say, have string in 2d array follows:

[['shoo-be-doo-be-doo-da-day', 'henry cosby'],  ['my cherie amour (song)', 'stevie wonder'],  ["signed, sealed, delivered i'm yours", 'stevie wonder]] 

so can search in text file string e.g.: ['shoo-be-doo-be-doo-da-day', 'henry cosby']['', ''] ['', ''].... in file.txt lines this:

abcd shoo-be-doo-be-doo-da-day skakk gkdka kkhhf henry cosby. gfigka stevie wonder hfkhf hghhg fghh cherie amour. fhsgs hlghhg  henry cosby shoo-be-doo-be-doo-da-day gkgkl. 

then should return whole line marking matches string. 1d array following code works:

def search(word, sentences):     return[i in sentences if word in i] 

for above 2d-array, how proceed on?

how this:

def search(sentences, words):   return [s s in sentences if all([w in s w in words])] 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -