Python API wrapper for 和风天气
暂时只支持异步(async)调用,因为最初是为集成在 homeassistant 开发的 :)
import aiohttp
import asyncio
from python_qweather import QWeather, WeatherNow
async def test_now_weather():
async with aiohttp.ClientSession() as client_session:
q = QWeather(api_key=os.environ['QWEATHER_APIKEY'], session=client_session, location_key='101010100')
now_weather = await q.async_get_now_weather()
w = WeatherNow.from_dict(now_weather)
print(w)
asyncio.run(test_now_weather())