开发者

How to retrieve dirs in a zipfile using python?

How do I traverse the contents of a zip file in python without having to extract them?

If extracting is the only way, is it efficient if I create a unique temp folder and extract them there then traverse and remove the temp folder afterwards开发者_JS百科?


Use the namelist() method of the ZipFile class to get a list of all of the filenames in the archive without having to extract them. For example:

import zipfile

myzip = zipfile.ZipFile('myzip.zip', 'r')
filenames = myzip.namelist()
# Do something with filenames
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜