21 Nov 2009

python下载文件

python下载文件,没有测试对大文件的效率问题,估计不咋样.


import urllib2

url = r'http://www.blogger.com/img/icon_logo32.gif'
data = urllib2.urlopen(url).read()
path = r'c:\1.gif'
f = open(path,'wb')
f.write(data)
f.close()

No comments :

Post a Comment