fileinput - remove lines in file
furas Jul 22nd, 2018 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- # keeps lines with char "a"
- # line has '\n' so print doesn't have to add own '\n'
- import fileinput
- for line in fileinput.input('test.txt', 'w'):
- if 'a' in line:
- print(line, end='')
RAW Paste Data