如何在python中从url保存.doc文件?
我正在尝试找出如何从internet下载/保存.doc文件到我计算机上的某个位置 我熟悉urllib2模块和.read(),但我还不知道如何将格式化的.doc文件保存到计算机上的某个位置。这可能吗?使用库,您可以这样做:如何在python中从url保存.doc文件?,python,download,save,Python,Download,Save,我正在尝试找出如何从internet下载/保存.doc文件到我计算机上的某个位置 我熟悉urllib2模块和.read(),但我还不知道如何将格式化的.doc文件保存到计算机上的某个位置。这可能吗?使用库,您可以这样做: r = requests.get(url, stream=True) if r.status_code == 200: with open('document.doc', 'wb') as f: for chunk in r.iter_content()
r = requests.get(url, stream=True)
if r.status_code == 200:
with open('document.doc', 'wb') as f:
for chunk in r.iter_content():
f.write(chunk)
f.close()