简体   繁体   中英

using zipinfo and zipfile in python

I want to know the difference between using

z = zipfile.ZipFile('zippedfile.zip')

txt = z.getinfo(filename).comment.decode('utf-8')

and

txt = zipinfo(filename).comment.decode('utf-8')

they don't give me the same result, despite it suppose to "as i understand from the documentation"

You're not supposed to create ZipInfo objects manually; they're automatically constructed by ZipFile in order to represent each file in the archive.

ZipInfo doesn't know how to extract a file from a .zip - that's what ZipFile does. (Even if ZipInfo could extract a file, how would it know which .zip the filename you provided belongs to?)

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