Downloading file using requests module creates an empty file
问题 After a few tentatives and seeing a lot of examples and questions around here I can't figure out why I'm not able to download a file using requests module, the File i'm trying to download is around 10mb only: try: r = requests.get('http://localhost/sample_test', auth=('theuser', 'thepass'), stream=True) with open('/tmp/aaaaaa', 'wb') as f: for chunk in r.iter_content(chunk_size=1024): f.write(chunk) except: raise Empty file: [xxx@xxx ~]$ ls -ltra /tmp/aaaaaa -rw-rw-r--. 1 xxx xxx 0 Jul 21 12