我想顯示我的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我想是的,是的。 –