小编use*_*585的帖子

获取远程zip文件并列出其中的文件

我正在开发一个小型Google App Engine项目,我需要从URL中获取远程zip文件,然后列出zip存档中包含的文件.

我正在使用该zipfile模块.

这是我到目前为止所提出的:

# fetch the zip file from its remote URL
result = urlfetch.fetch(zip_url)

# store the contents in a stream
file_stream = StringIO.StringIO(result.content)

# create the ZipFile object
zip_file = zipfile.ZipFile(file_stream, 'w')

# read the files by name
archive_files = zip_file.namelist()
Run Code Online (Sandbox Code Playgroud)

不幸的是,archive_files列表总是长度为0.

我有什么想法我做错了吗?

python zip google-app-engine

3
推荐指数
1
解决办法
1031
查看次数

标签 统计

google-app-engine ×1

python ×1

zip ×1