In python, how can you delete the third forth and fifth line of a text file? -


there question deleting first 3 , last line, used .writelines(), work if want delete outside lines, not delete lines in the middle.

any ways of deleting multiple specific lines anywhere in text file in python?

please, please, please help!!

try following code:

with open('input.txt') f, open('output.txt', 'w') fout:     fout.writelines(line lineno, line in                          enumerate(f, 1) if lineno not in (3,4,5)) 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -