On 01Jul2015 21:51, Peter Otten <__pete...@web.de> wrote:
zljubi...@gmail.com wrote:
But how to read chunks?
Instead of
data = response.read() # a `bytes` object
out_file.write(data)
use a loop:
CHUNKSIZE = 16*1024 # for example
while True:
data = response.read(CHUNKSIZE)
if not data:
break
out_file.write(data)
It might be worth noting here that Peter's "chunk" is just an arbitrary amount
of data to read in a unit. I'm only mentioning this because the HTTP
specification has a "chunked-encoding" used to return binary files, and we are
not talking about _those_ chunks.
Cheers,
Cameron Simpson <c...@zip.com.au>
Life is uncertain. Eat dessert first. - Jim Blandy
--
https://mail.python.org/mailman/listinfo/python-list