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'))
posted @ 2021-03-31 15:17  唐大侠的小迷弟  阅读(323)  评论(0编辑  收藏  举报