简体   繁体   中英

How to process a string as a file to contruct a ZipFile object?

I am currently pulling data from a database with blobs. I retrieve the blob from the database, but I need to parse the text. the ZipFile class takes in files not strings, so what would be a good way to solve this?

import zipfile

data= request.files["file"].read() #this is just binary data
zipfile.ZipFile(data)

use io.BytesIO or io.StringIO
essentially u just need file-like interface

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM