问题描述
enter image description here我一直试图弄清楚如何解析从我使用的 API 中获取的数据,以便我可以将其转换为 MysqL 并将其添加到表中,但我没有真的知道该怎么做,因为我对 python 还很陌生。
我的代码是这样的:
from weatherbit.api import Api
api_key = "API key"
lat = 39.7029
lon = 75.1118
api = Api(api_key)
# Set the granularity of the API - Options: ['daily','hourly','3hourly']
# Will only affect forecast requests.
api.set_granularity('daily')
# Or City,state,and country:
forecast = api.get_forecast(city="Glassboro",state="New Jersey",country="US")
# To get a daily forecast of temperature,and precipitation:
print (forecast.get_series(['temp','precip']))
# Get daily history by lat/lon:
api.set_granularity('daily')
history = api.get_history(lat=lat,lon=lon,start_date='2021-03-04',end_date='2021-03-05')
# To get a daily time series of temperature,precipitation,and rh:
print (history.get_series(['precip','temp','rh']))
...
input ('')
我收到了它的响应,但它的可读性不是很好,不能用于添加到 MysqL 中的表中,有什么办法可以做到这一点?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)