import urllib2import reimport zipfile#tell the user what is happeningprint("Calibre is Updating")#download the pageurl = urllib2.urlopen ( "http://sourceforge.net/projects/calibre/files" ).read()#determin current versionresult = re.search('title="/[0-9.]*/([a-zA-Z\-]*-[0-9\.]*)',url).groups()[0][:-1]#download filedownload = "http://status.calibre-ebook.com/dist/portable/" + resulturllib2.urlopen( download )#saveoutput = open('install.zip','w')output.write(zipfile.Zipfile("install.zip",""))output.close()解决方法 你不需要为此使用zipfile.Zipfile(以及你使用它的方式,以及urllib2.urlopen也有问题).相反,您需要将urlopen结果保存在变量中,然后读取它并将该输出写入.zip文件.试试这段代码:
#download filedownload = "http://status.calibre-ebook.com/dist/portable/" + resultrequest = urllib2.urlopen( download )#saveoutput = open("install.zip","w")output.write(request.read())output.close()总结
以上是内存溢出为你收集整理的使用Python保存下载的ZIP文件全部内容,希望文章能够帮你解决使用Python保存下载的ZIP文件所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)