此python文件中是否存在任何代码问题?

问题描述 投票:0回答:1

[enter image description here我正在尝试使用附加的python文件下载批处理图像,但是当我运行它时,它显示此错误如何解决?谢谢

from google_images_download import google_images_download   
response = google_images_download.googleimagesdownload()  

search_queries = ['Fan' , 'Mouse' ,'Phone','Chair','Bottle'] 

def downloadimages(query): 
    arguments = {"keywords": query, 
                 "format": "jpg", 
                 "limit":200, 
                 "print_urls":True, 
                 "size": 300*300, 
                 "aspect_ratio":"wide"} 
    try: 
        response.download(arguments) 

    # Handling File NotFound Error     
    except FileNotFoundError:  
        arguments = {"keywords": query, 
                     "format": "jpg", 
                     "limit":4, 
                     "print_urls":True,  
                     "size": "medium"} 
        try: 
           response.download(arguments)  
        except: 
            pass
for query in search_queries: 
    downloadimages(query)  
    print()  

,

python
1个回答
0
投票

请参见下面的大小和精确大小选择列表,并相应地修改您的代码:

parser.add_argument('-s', '--size', help='image size', type=str, required=False,
                            choices=['large','medium','icon','>400*300','>640*480','>800*600','>1024*768','>2MP','>4MP','>6MP','>8MP','>10MP','>12MP','>15MP','>20MP','>40MP','>70MP'])

parser.add_argument('-es', '--exact_size', help='exact image resolution "WIDTH,HEIGHT"', type=str, required=False)
© www.soinside.com 2019 - 2024. All rights reserved.