# 文件下载方法
from urllib.request import urlretrieve
import requests

# 第一
urlimage  = 'https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tar.xz'
urlretrieve(urlimage, "logo.tar.xz")

#第二
ir = requests.get(urlimage, stream=True)
print (ir.status_code)
if ir.status_code == 200:
    with open('logo2.tar.xz', 'wb') as f:
        for chunk in ir:
            f.write(chunk)


#第三
ir = requests.get(urlimage)
print (ir.status_code)
if ir.status_code == 200:
    with open('logo3.tar.xz', 'wb') as f:
        f.write(ir.content)

 

相关文章:

  • 2021-11-24
  • 2022-01-04
  • 2022-02-23
  • 2022-12-23
  • 2021-06-29
  • 2021-12-10
  • 2021-08-24
  • 2022-01-10
猜你喜欢
  • 2021-12-10
  • 2021-11-23
  • 2021-12-10
  • 2021-08-28
  • 2021-06-18
  • 2021-09-01
  • 2022-02-07
相关资源
相似解决方案