Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在尝试使用 numpy.fromfile() 读取一个非常大(几 GB)的二进制文件。一次读取整个文件会产生内存不足错误,因此我想创建一个循环来一次读取和处理 N 块数据。类似于以下内容:
while True: numpy.fromfile(f, recordType, N) # proccess data if f.EOF(): break
如何检测何时到达文件末尾,以便中断循环?
while True: a = numpy.fromfile(f, recordType, N) # proccess data if a.size < N: break