How to read a text file in reverse using python 2.2 -
this question has answer here:
- read file in reverse order using python 11 answers
is there way read text file in reverse python 2.2? =)
try following.
# method not using `reverse` function def read_file_reversed(filename): return open(filename, 'r').readlines()[::-1]
it reverses list using slicing.
mindful these load entire file memory.
Comments
Post a Comment