ASYNC Google日历API客户端
aiogc的Python项目详细描述
AIOGC
Async Google Calendar API Client for Python 3
安装
在终端中运行此命令:
pip install aiogc
用法
下面的代码将在最近5天内打印即将发生事件的摘要和start
和end
日期时间。
importasyncioimportdatetimeimportaiohttpfromaiogcimportevents,modelsc=models.Credentials(client_id='<your_client_id>',client_secret='<your_client_secret>',scopes=['<your_scope1>','your_scope2'],refresh_token='<your_refresh_token>')asyncdefmain():asyncwithaiohttp.ClientSession()ass:es=awaitevents.list(calendar_id='<your_calendar_id>',credentials=c,session=s,singleEvents='true',timeMin=datetime.datetime.now().isoformat(),timeMax=(datetime.datetime.now()+datetime.timedelta(days=5)).isoformat(),orderBy='startTime',)foreines:print(f'{e.summary}:\n{e.start.dateTime} – {e.end.dateTime}')if__name__=='__main__':loop=asyncio.get_event_loop()loop.run_until_complete(main())