背景:把数据从指定位置下载保存到本地
- 文件下载
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)
- 补充大文件读取
with open(file_name.'rb') as f:
for content in f:
print(content.decode('utf8'))