此方法我使用键和参数以字典形式调用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())
解决方案:响应= request.GET(URL,params = params)