python的requests模塊下載文件?
import requests
res = requests.get('http://www.xx.xx/xxxx/xx.dat')
res.raise_for_status()
newfile = open('/home/xx/xx.dat', 'wb') # 本地文件
for chunk in res.iter_content(10240):
newfile.write(chunk)
newfile.close()
python的requests模塊下載文件?
import requests
res = requests.get('http://www.xx.xx/xxxx/xx.dat')
res.raise_for_status()
newfile = open('/home/xx/xx.dat', 'wb') # 本地文件
for chunk in res.iter_content(10240):
newfile.write(chunk)
newfile.close()