读取字节码格式的zip文件

import zipfile
import io

local_file_path = "test.zip"
new_zip = io.BytesIO()
fp = zipfile.ZipFile(new_zip, 'w', zipfile.ZIP_DEFLATED, False)

with zipfile.ZipFile(local_file_path, mode='r') as f:
    for name in f.filelist:
        print("name: ", name)
        fp.writestr(name, f.open(name).read())

fp.close()
print(new_zip.getvalue())

  

posted on 2023-04-03 18:12  帅胡  阅读(16)  评论(0编辑  收藏  举报

导航