One way would be to read each line of the file into a list. Then find the index of the first list item to remove and the last list item to remove and use del[first:last+1]
to remove those, then use list.insert()
to put in the new rows starting at first
.
solved Deleting lines between tags and inserting new lines [closed]