urlretrieve生成“没有这样的文件”错误

时间:2017-03-26 13:23:45

标签: python python-3.x

我遇到以下问题:

objectlist = ["1", "2", "3"]
namelist = ["name1.png", "name2.png", "name3.png"]    

for i in objectlist:
    for j in namelist:
    url = "https://your.domain/id="+i
    urllib.request.urlretrieve(url, j)

我需要按顺序“1”,“2”和“3”访问URL,并根据“name1.png”,“name2.png”和“name3.png”下载重命名的PNG图像。但是,我收到了这个错误:

    CeXs-MacBook-Air:Report Graphics danielvincenzi$ python3 main.py
    Traceback (most recent call last):
      File "main.py", line 55, in <module>
        download(objectid, nameid)
      File "main.py", line 53, in download
        urllib.request.urlretrieve(url, j)
      File"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/urllib/request.py", line 258, in urlretrieve          
        tfp = open(filename, 'wb')
    FileNotFoundError: [Errno 2] No such file or directory: 'name1.png'

你能帮助我吗?

谢谢,

0 个答案:

没有答案