我想显示我的python代码中的平均温度。使用pyowm获取平均tempature(python)
我发现http://openweathermap.org/,与他们的API我提出了以下的代码:
import pyowm
api = pyowm.OWM('Your API key')
collectinfo = api.weather_at_place("Gorinchem,nl")
short = collectinfo.get_weather()
temperature = short.get_temperature('celsius')
print(temperature)
尚tempature功能例如显示多个变量
温度“:18.72, 'temp_max':20.0, 'temp_min':17.0, 'temp_kf':无
我想刚刚已经平均tempture写入到一个变量,这样我可以在我的程序中使用它。
经过一番搜索,我发现下面的代码行:
部分average_temperature(unit='kelvin')
class pyowm.webapi25.historian.Historian(station_history)
链接到文件:https://pyowm.readthedocs.io/en/latest/pyowm.webapi25.html#module-pyowm.webapi25.observation
(使用Ctrl + F键,搜索摄氏度它是第一个弹出)
我不知道如何使用功能为平均温度。
任何人谁可以帮助开始编码器:)?
我知道我在用的API,并且我不认为这将是恶意的。所以eval的安全风险是不对的? –
@AntonvanderWel我想是的,是的。 –