import struct
import string
datafile ='ch02-fixed-width-1M.data'
mask='9s14s5s'// mask告诉struct模块的Struct方法如何去读取定宽的数据
withopen(datafile,'r')as f:for line in f:
fields = struct.Struct(mask).unpack_from(line)print('fields:'+[field.strip()for field in fields]