How to read a file in reverse order?

前端 未结 21 2567
礼貌的吻别
礼貌的吻别 2020-11-22 04:51

How to read a file in reverse order using python? I want to read a file from last line to first line.

21条回答
  •  难免孤独
    2020-11-22 05:45

    If you are concerned about file size / memory usage, memory-mapping the file and scanning backwards for newlines is a solution:

    How to search for a string in text files?

提交回复
热议问题