requests response.iter_content() gets incomplete file ( 1024MB instead of 1.5GB )?

后端 未结 3 1929
醉梦人生
醉梦人生 2021-02-13 21:46

hi i have been using this code snippet to download files from a website, so far files smaller than 1GB are all good. but i noticed a 1.5GB file is incomplete

# s         


        
3条回答
  •  太阳男子
    2021-02-13 22:10

    I think you forgot to close req.

    from the requests author said, "If you find yourself partially reading request bodies (or not reading them at all) while using stream=True, you should make the request within a with statement to ensure it’s always closed:"

    http://2.python-requests.org//en/latest/user/advanced/#body-content-workflow.

提交回复
热议问题