Update weatherQuery.py

This commit is contained in:
Alpherg 2024-09-25 12:31:15 +08:00 committed by GitHub
parent 428f66ff64
commit 4b59446556
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 0 deletions

View File

@ -34,6 +34,11 @@ async def querys(city, API_KEY) -> str:
f'气温{data["results"][0]["now"]["temperature"]}℃。'
except (httpx.NetworkError, httpx.HTTPStatusError, KeyError):
return f'抱歉,没有找到{city}的天气数据。'
async def fullQuery(city):
async with httpx.AsyncClient() as client:
r=await client.get(f"https://api.lolimi.cn/API/weather/?city={city}")
data=r.json()
return data["data"]
if __name__ == '__main__':