我正在开发一个小型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.
我有什么想法我做错了吗?