mardi 26 juillet 2016

Search Multiple Strings (from File) in a file and print the line

Again apologies for been noob here ; trying below code for searching multiple strings read from keywords and search in f and printing the line. it works if i have only one keyword but not if i have more then one

keywords = input ("Please Enter keywords path as c:/example/ n :")
 keys = open((keywords) , "r").readline()        
        with open("c:/saad/saad.txt") as f:
                         for line in f:
                                if (keys) in line:
                                        print (line)

Aucun commentaire:

Enregistrer un commentaire