此方法我使用dictinoary形式的键和参数来调用Weather API,但其抛出错误的行:
response = request.GET(url, params=params)
TypeError:“ dict”对象不可调用
def get_weather():
print('this is the weather')
user = entry.get()
key = '6557bbd7dbca062ddf4fe0XXXXXX'
# api.openweathermap.org/data/2.5/weather?q={city name},{country code}
url = 'https://api.openweathermap.org/data/2.5/weather'
params = {'APPID':key, 'q': user, 'units':'metric'}
response = request.GET(url, params=params)
#print(response.JSON()) this also didn't worked
return jsonify(response.JSON())
答案 0 :(得分:0)
解决方案:响应= request.GET(url,params = params)
我正在使用请求,并导入了请求库,我应该在其中使用请求库,并从中请求(.URL(param = params))。
我对其进行了纠正,并获得了所需的输出。 谢谢