一个Python包,它可以快速访问大文件中的任何行,而不会占用高内存成本。

linecache-light的Python项目详细描述


LineCache caches the line position of a file in the memory. Everytime it access a line, it will seek to the related postion and readline(). Noticing that it may cost some time when you first cache lines of a file.

Usage:

from linecache_light import LineCache

linecache = LineCache(‘a.txt’, cache_suffix=’.cache’)

num_lines = len(linecache)

line_0 = linecache[0]

line_100 = linecache[100]

line_indexing= linecache[[2,3,4,5]]

line_indexing = linecache[-1]

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java程序不断抛出错误。springframework。豆。工厂BeanCreationException弹簧靴   Java中的SQL SELECT语句   java如何在邻接链表中列出链表的所有成员   java为什么需要显式导入springsecurityweb依赖项?   SQLException中的java提取参数   eclipse如何使用使用java在rapidminer中创建的模型   java转换字符串列表日期列表   java是否可以使用Selenium或任何其他工具自动化RDP会话?   Scala/Java解析只有日期部分的字符串   使用AES解密时的java Stringindexoutofboundsexception   java日期类问题:日期对象被设置为我没有设置的对象   java如何修改IllegalArgumentException以包含负值?   sockets Java。net服务器示例不起作用   java每隔这么多字符就有一个空格