我有一个包含多个文件的自定义存档文件。我知道这些文件的偏移量和长度,并想要提取它们。现在,我的代码只创建了空白文件,我不知道如何读取数据。根据我所知道的情况,如何从档案中获取数据?
inc c = c + 1
答案 0 :(得分:4)
with open(file_path, 'rb') as f:
for start, length, name in zip(offsets, lengths, names):
f.seek(start)
with open(name, 'wb') as out:
out.write(f.read(length))
答案 1 :(得分:0)
infile = (r'path\to\file.xxx')
start,length =(file_sta),(file_len)
with open(infile, 'rb') as infile_:
infile_read = infile_.read(file_sta:file_len)
with open(((infile)+'alt'),'wb')as out:
out_write = out.write(infile_read)