Google日历API提供的信息比所需的更多信息
我是初学者的程序员,所以不要仇恨。
我有以下电话:
eevents = service.events().list(calendarId='primary', pageToken=page_token, timeMax = "2022-07-01T00:00:00Z",
timeMin = "2022-06-28T00:00:00Z").execute()
for event in events['items']:
print(event.items())
page_token = events.get('nextPageToken')
if not page_token:
break
但是我会在指定的时间范围之外获得事件,例如:|
('start', {'dateTime': '2022-05-02T10:00:00+02:00', 'timeZone': 'Europe/Prague'}), ('end', {'dateTime': '2022-05-02T11:00:00+02:00', 'timeZone': 'Europe/Prague'}),
此外, https://developers.google.com/日历/api/v3/reference/events/list 如下:
{
"kind": "calendar#events",
"etag": etag,
"summary": string,
"description": string,
"updated": datetime,
"timeZone": string,
"accessRole": string,
"defaultReminders": [
{
"method": string,
"minutes": integer
}
],
"nextPageToken": string,
"nextSyncToken": string,
"items": [
events Resource
]
}
但是除了预期的字典键和值,我在元组中获得了信息。例如:
('kind', 'calendar#event'), ('etag', '"3306952077924000"'), ('id', '5qcpuj5r1k35v533slhljtgh9g'), ('status', 'confirmed')
第二件事很有意义。我的事件中还有更多的基线信息,因此还有更多的信息添加,但是由于它比预期的要多。
这确实是第一个让我困扰我的事件的问题。第二个问题只是直觉,这两件事可能是相关的。
I am a beginner programmer so pls no hate.
I have the following call:
eevents = service.events().list(calendarId='primary', pageToken=page_token, timeMax = "2022-07-01T00:00:00Z",
timeMin = "2022-06-28T00:00:00Z").execute()
for event in events['items']:
print(event.items())
page_token = events.get('nextPageToken')
if not page_token:
break
But I get events outside the the specified time frame such as:|
('start', {'dateTime': '2022-05-02T10:00:00+02:00', 'timeZone': 'Europe/Prague'}), ('end', {'dateTime': '2022-05-02T11:00:00+02:00', 'timeZone': 'Europe/Prague'}),
Additionally, the expected response at https://developers.google.com/calendar/api/v3/reference/events/list is the following:
{
"kind": "calendar#events",
"etag": etag,
"summary": string,
"description": string,
"updated": datetime,
"timeZone": string,
"accessRole": string,
"defaultReminders": [
{
"method": string,
"minutes": integer
}
],
"nextPageToken": string,
"nextSyncToken": string,
"items": [
events Resource
]
}
But in addition to the expected dictionary keys and values I get information in tuples. eg.:
('kind', 'calendar#event'), ('etag', '"3306952077924000"'), ('id', '5qcpuj5r1k35v533slhljtgh9g'), ('status', 'confirmed')
This second thing kind of makes sense. I have more than the baseline information in the event, so there is more info adde but since it is more than expected it gets added into tuples.
It really is the first issue of getting events outside scope that bothers me. The second issue is just hunch that the two things could be related.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我将回答标题问题:
对于事件['items']中的事件:
正在通过事件进行循环,其中事件是指定的此处event.items()
返回键值对的列表作为元组。没有额外的信息。I'll answer the title question:
for event in events['items']:
is looping through the events, where events is a dict specified hereevent.items()
returns a list of key value pairs as tuples. There is no extra information.