python流媒体下载&大文件读取

背景:把数据从指定位置下载保存到本地

  1. 文件下载
res = requests.get('https://www.xxxx.com',stream=True)
with open(file_name.wav,'wb') as f_w:
    for a in res.iter_content(chunk_size=32):#iter是iter
        f_w.write(a)
  1. 补充大文件读取
with open(file_name.'rb') as f:
    for content in f:
        print(content.decode('utf8'))
原文地址:https://www.cnblogs.com/wjlv/p/14601614.html