Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to remove all line in file python

with open("target.txt", "r+") as f:
    d = f.readlines()
    f.seek(0)
    for i in d:
        if i != "line you want to remove...":
            f.write(i)
    f.truncate()
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #remove #line #file #python
ADD COMMENT
Topic
Name
3+6 =