我有这个问题使用谷歌日历API,我试图让它找出什么颜色是事件,但由于一些奇怪的原因,它不起作用。我试图找到一个解决办法,但到目前为止没有希望。在
def greet(self):
self.pikk=(self.variable.get())
print(self.pikk)
self.ckbx = self.ivar.get()
print(self.ckbx)
self.SCOPES = "https://www.googleapis.com/auth/calendar"
self.store = file.Storage('credentials.json')
self.creds = self.store.get()
if not self.creds or self.creds.invalid:
self.flow = client.flow_from_clientsecrets('client_secret.json', self.SCOPES)
self.creds = tools.run_flow(self.flow, self.store)
self.service = build('calendar', 'v3', http=self.creds.authorize(Http()))
self.now = datetime.datetime.utcnow().isoformat() + 'Z'
self.events_result = self.service.events().list(calendarId='primary', timeMin=self.now,
maxResults=10, singleEvents=True,
orderBy='startTime').execute()
self.events = self.events_result.get('items', [])
self.lievent = []
if not self.events:
print('No upcoming events found.')
for self.event in self.events:
self.start = self.event['start'].get('dateTime', self.event['start'].get('date'))
print(self.start, self.event['colorId'])
self.event['colorId']
返回颜色的id。要获得相关的颜色值,必须调用colors().get()
方法。在colors = service.colors().get().execute()
下面是如何在您的示例中使用它:
https://developers.google.com/calendar/v3/reference/colors/get
希望有帮助!!如果您有任何疑问,请随时询问:)
相关问题 更多 >
编程相关推荐