它提供了一个有用的函数,可以让您从末尾读取行。
tacit的Python项目详细描述
它提供了一个有用的函数tac,可以让您读取文件中的行 从头到尾。它的工作方式类似于shell中的tac命令。
它将文件读入一个固定的缓冲区,并按顺序生成行,因此它是可组合的 用于大文件。(例如大对数)
安装
您可以通过pypi安装它,
sudo pip install tacit
或者手动下载。
示例
文件内容:
The first line. The second line. The last line.
代码:
for line in open(path): print line, print from tacit import tac for line in tac(path): print line,
输出:
The first line. The second line. The last line. The last line. The second line. The first line.