Python Random Access File

前端 未结 7 2053
借酒劲吻你
借酒劲吻你 2020-12-01 16:10

Is there a Python file type for accessing random lines without traversing the whole file? I need to search within a large file, reading the whole thing into memory wouldn\'t

相关标签:
7条回答
  • 2020-12-01 17:14

    The File object supports seek but make sure that you open them as binary, i.e. "rb".

    You may also wish to use the mmap module for random access, particularly if the data is in an internal format already.

    0 讨论(0)
提交回复
热议问题