Wednesday, July 8, 2015

Python program to Copy a line containing a word to other file

with open("test.txt") as f:
    lines = f.readlines()
    lines = [l for l in lines if "Python" in l]
     with open("out.txt", "w") as f1:

        f1.writelines(lines)