zoukankan      html  css  js  c++  java
  • 使用requests下载文件

    代码示例:

    import requests
    
    url_download='http://127.0.0.1:5000/gotest/api/download/mini_32G_ios_build_official_develop_30.ipa'
    
    r = requests.get(url_test)
    
    #保存文件至本地 with open(
    'filename.ipa','wb') as f: f.write(r.content)

    效果如图:

     

    知识点:

    resp.text返回的是Unicode型的数据。

    resp.content返回的是bytes型也就是二进制的数据。

    取文本,可以通过r.text。
    取图片,文件,则可以通过r.content
  • 相关阅读:
    Careercup
    Careercup
    Careercup
    Careercup
    Careercup
    Careercup
    Careercup
    Careercup
    Careercup
    Careercup
  • 原文地址:https://www.cnblogs.com/kaerxifa/p/14338936.html
Copyright © 2011-2022 走看看