Advertisement
furas

fileinput - remove lines in file

Jul 22nd, 2018
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.20 KB | None | 0 0
  1. # keeps lines with char "a"
  2. # line has '\n' so print doesn't have to add own '\n'
  3.  
  4. import fileinput
  5.  
  6. for line in fileinput.input('test.txt', 'w'):
  7.     if 'a' in line:
  8.         print(line, end='')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement