def read_f(self, offset =None):
if offset is not None :
self.fid.seek(offset)
d = { }
for key, fmt in self.description :
fmt = '<' + fmt # insures use of standard sizes
buf = self.fid.read(struct.calcsize(fmt))
if len(buf) != struct.calcsize(fmt) : return None
val = list(struct.unpack(fmt , buf))
for i, ival in enumerate(val):
if hasattr(ival, 'split'):
val[i] = ival.split('\x00', 1)[0]
if len(val) == 1:
val = val[0]
d[key] = val
return d
评论列表
文章目录