downloading files

Carsten Haese carsten at uniqsys.com
Fri Aug 3 15:10:45 EDT 2007


On Fri, 2007-08-03 at 11:48 -0700, Ehsan wrote:
> I foundd this code in ASPN  Python Cookbook for downloading files in
> python but when it finished downloading files the files became
> corrupted and didn't open, the files in internet havn't any problem:
> 
> 
> def download(url,fileName):
> 	"""Copy the contents of a file from a given URL
> 	to a local file.
> 	"""
> 	import urllib
> 	webFile = urllib.urlopen(url)
> 	localFile = open(fileName, 'w')
> [...]

Try 'wb' instead of 'w'.

-- 
Carsten Haese
http://informixdb.sourceforge.net





More information about the Python-list mailing list