2025-09-10:仓库迁移
This commit is contained in:
9
5.文件与IO/8.对固定大小的记录进行迭代.py
Normal file
9
5.文件与IO/8.对固定大小的记录进行迭代.py
Normal file
@@ -0,0 +1,9 @@
|
||||
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='')
|
Reference in New Issue
Block a user