python how to delete certain line number of file code example
Example: python how to delete certain line number of file
#!/usr/bin/python
def deleteLine():
fn = 'myfile'
f = open(fn)
output = []
str="The string i wish to delete
for line in f:
if not line.startswith(str):
output.append(line)
f.close()
f = open(fn, 'w')
f.writelines(output)
f.close()
deleteLine()