how to download a zip or rar file to local machine using python?

James Stroud jstroud at
Wed Mar 8 06:29:35 CET 2006

dongdong wrote:
> I wrote as following:
>   content=urllib2.urlopen("").read()
>   f=open("d:\\",'a+',1)
>   f.writelines(content)
> the zip file has been download to my machine,but when be unzip , error
> occurs:
> " there is an  error at the end of the file"


Here you want to open as a text file (default) for appending, in 
both read and write mode.

I think sufficient would be


For opening a new file and writing as binary.

Then you will want:




James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

More information about the Python-list mailing list