Working in the Python interpreter, the following code works ... but with a console output of: 2048 2048 ... 2048 2048
Is there anyway to run the fd.write(chunk) statemen
The Python interpreter prints the return value of functions by default. Write returns the number of bytes it writes. If you don't want to see that, just store it in a variable which you never print, e.g.:
r = requests.get(url, stream=True)
with open('output.jpg', 'wb') as fd:
for chunk in r.iter_content(2048):
bytes = fd.write(chunk)