1
我想从Python中的大型二进制数据文件中随机读取块,至今我还没有找到解决我的问题的好方法。在Python中阅读大型二进制文件的部分
我到目前为止是以下内容,但它只能读取第一个n整数,并且无法在文件的其他位置启动。
import numpy as np
#Pick an n here.
f = open("test2.rd14")
a = np.fromfile(f, dtype = np.uint16, count=int(n))
此外,在过大的文件,使用
with open("test2.rd14") as file:
filecontent = file.read()
你应该检查[this](http://stackoverflow.com/questions/1035340/reading-binary-file-in-python-and-looping-over-each-byte)它可能有帮助。 – kessi