【发布时间】:2019-01-06 02:56:42
【问题描述】:
我只是在学习 python,我想知道是否有更好的方法从 res 变量中提取最新的温度。
from noaa_sdk import noaa
from datetime import datetime
date = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
n = noaa.NOAA()
res = n.get_observations('25311', 'US', start=date, end=None, num_of_stations=1)
temp= (next(res))
value =(temp.get('temperature'))
temperature = (value['value'])
temperature = temperature*9/5+32
print(temperature, ' F')
【问题讨论】:
标签: python dictionary generator