从intern下载zip文件时出现问题

2024-05-11 18:33:05 发布

您现在位置:Python中文网/ 问答频道 /正文

从internet下载zip文件时出现问题

import requests
url = '"file:///Users/rituraj/Downloads/fo01NOV2018bhav.csv%20(1).zip"'

# download the file contents in binary format
r = requests.get(url)

with open("/Users/rituraj/Desktop/bhavcopy/myzip.zip","wb") as zip:
    zip.write(r.content)

我得到的错误:

    AttributeError Traceback (most recent call last) <ipython-input-17-8b95bb6c7ef7> in <module> 
   3 import zipfile 4 ----> 5  urllib.urlretrieve('file:///Users/rituraj/Downloads/fo01NOV2018bhav.csv%20.zip') 6 7 
    # download the file contents in binary format AttributeError: module 'urllib' has no attribute 'urlretrieve' 

Tags: theinimportformaturldownloaddownloadscontents