Python 类型错误:';方法';对象在运行代码时不可下标

Python 类型错误:';方法';对象在运行代码时不可下标,python,api,typeerror,Python,Api,Typeerror,运行此命令时,我得到类型错误:“method”对象不可下标,这是因为您需要 json\u weather=get\u weather.json() 它是一种将json解析为对象的方法,这是因为您需要 json\u weather=get\u weather.json() 它是一种将json解析为对象的方法 import requests def temp(): get_weather = requests.get('https://api.openweathermap.org/data/2.

运行此命令时,我得到类型错误:“method”对象不可下标,这是因为您需要
json\u weather=get\u weather.json()

它是一种将json解析为对象的方法,这是因为您需要
json\u weather=get\u weather.json()

它是一种将json解析为对象的方法

import requests
def temp():
  get_weather = requests.get('https://api.openweathermap.org/data/2.5/weather?zip=10970,us&appid=50b55ef1602086c74b71f56c6df14996')
  json_weather = get_weather.json
  kelvin = float(json_weather['main']['temp'])
  print(kelvin)
temp()