I have some files like this:
a:...
a:...
a:...
a:...
count = ...
and I just need to keep the a:...
values lines.
What is the fastest way to remove that last line (which always starts with count =
) ?
I have some files like this:
a:...
a:...
a:...
a:...
count = ...
and I just need to keep the a:...
values lines.
What is the fastest way to remove that last line (which always starts with count =
) ?
You can try this solution:
lines = file.readlines()
lines = lines[:-1]
After opening your file in python as reading mode you could do that for deleting your last line.
You could use readlines()
function and apply the slice like
lines = yourfile.readlines()
lines = lines[:-1]
Many other methods could be found here