Asked By – Nimmy
How to read a file in reverse order using python? I want to read a file from last line to first line.
Now we will see solution for issue: How to read a file in reverse order?
for line in reversed(open("filename").readlines()): print line.rstrip()
And in Python 3:
for line in reversed(list(open("filename"))): print(line.rstrip())