from functools import partial if __name__ == '__main__': RECORD_SIZE = 32 # partial函数主要起参数固定的作用,接受一个函数和一组预设参数,相当于给函数设置默认参数而不用修改函数 with open('5.文件与IO/4.bin_file.bin', 'rb') as f: records = partial(f.read, RECORD_SIZE) for record in records(): print(record, end='')