python dowload
Aahz
aahz at pythoncraft.com
Sat Feb 27 19:47:30 EST 2010
In article <2fWdnXOfjat-whnWnZ2dnUVZ_rGdnZ2d at insightbb.com>,
monkeys paw <monkey at joemoney.net> wrote:
>On 2/23/2010 3:17 PM, Tim Chase wrote:
>>
>> Sure you don't need this to be 'wb' instead of 'w'?
>
>'wb' does the trick. Thanks all!
>
>import urllib2
>a = open('adobe.pdf', 'wb')
>i = 0
>for line in
>urllib2.urlopen('http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf'):
> i = i + 1
> a.write(line)
Using a for loop here is still a BAD IDEA -- line could easily end up
megabytes in size (though that is statistically unlikely).
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"Many customs in this life persist because they ease friction and promote
productivity as a result of universal agreement, and whether they are
precisely the optimal choices is much less important." --Henry Spencer
More information about the Python-list
mailing list