【问题标题】:(AttributeError: 'NoneType' object has no attribute 'format') [closed](AttributeError:“NoneType”对象没有属性“格式”)[关闭]
【发布时间】:2021-01-17 14:00:56
【问题描述】:

api_key = 无

base_url = 无

def 配置请求(应用程序): 全局 api_key,base_url api_key = app.config['IMAGE_API_KEY'] base_url = app.config['API_BASE_URL']

def get_image(类别):

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

【问题讨论】:

    标签: python api flask


    【解决方案1】:

    app.config['API_BASE_URL']None。这就是我们能告诉你的全部内容。

    【讨论】:

    • 也许我们甚至不能告诉他们。问题中显示的代码显然不是整个代码,因为没有调用代码。所以也许我们没有显示的那部分代码有一个单独的<object>.format,它会引发异常。但这是一个合理的猜测,也是该问题应得的答案。
    猜你喜欢
    • 2015-09-24
    • 2015-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-24
    • 2019-01-01
    • 2021-12-26
    • 2019-07-23
    相关资源
    最近更新 更多