您可以按正常方式对文件对象使用seek,然后在中使用此文件对象
fromfile。这是一个完整的示例:
import numpy as npimport osdata = np.arange(100, dtype=np.int)data.tofile("temp") # save the dataf = open("temp", "rb") # reopen the filef.seek(256, os.SEEK_SET) # seekx = np.fromfile(f, dtype=np.int) # read the data into numpyprint x # [64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88# 89 90 91 92 93 94 95 96 97 98 99]


