(AttributeError:“ NoneType”对象没有属性“ format”)

时间:2020-10-01 19:48:41

标签: python api flask

api_key =无

base_url =无

def configure_request(app): 全局api_key,base_url api_key = app.config ['IMAGE_API_KEY'] base_url = app.config ['API_BASE_URL']

def get_image(category):

get_image_url = base_url.format(api_key,category)

with urllib.request.urlopen(get_image_url) as url:
    get_image_data = url.read()
    get_image_response = json.loads(get_image_data)

    image_results = None

    
    image_results = process_results(get_image_response)
    # print(image_results)

return image_results

1 个答案:

答案 0 :(得分:2)

app.config['API_BASE_URL']None。这就是我们所能告诉您的。