Python 转换时出现类型错误 JSON
Python TypeError while converting JSON
我这里有一些代码,用于我的 Slack 机器人:
import pyowm
owm.set_API_key('Key Here')
observation = owm.weather_at_id(4744326)
w = observation.get_weather()
jsondata= w.get_temperature('fahrenheit') # Here is our JSON Data.
response = (json.loads(jsondata))
print(response)
我要转换的 JSON 是:
{"temp": 47.05, "temp_max": 50.0, "temp_min": 42.8, "temp_kf": null}
当我 运行 执行此操作时,出现以下错误:
TypeError: the JSON object must be str, bytes or bytearray, not dict
有什么建议吗?
它return作为一本字典,我只是愚蠢地称它为错误。
我这里有一些代码,用于我的 Slack 机器人:
import pyowm
owm.set_API_key('Key Here')
observation = owm.weather_at_id(4744326)
w = observation.get_weather()
jsondata= w.get_temperature('fahrenheit') # Here is our JSON Data.
response = (json.loads(jsondata))
print(response)
我要转换的 JSON 是:
{"temp": 47.05, "temp_max": 50.0, "temp_min": 42.8, "temp_kf": null}
当我 运行 执行此操作时,出现以下错误:
TypeError: the JSON object must be str, bytes or bytearray, not dict
有什么建议吗?
它return作为一本字典,我只是愚蠢地称它为错误。