【问题标题】:Get attendees email from Google Calendar API - Python从 Google Calendar API 获取与会者电子邮件 - Python
【发布时间】:2020-11-04 00:13:31
【问题描述】:

我正在尝试从所有 Google 日历活动中提取电子邮件。我一直在关注其他链接 (Google Calendar API how to find attendee list),但出现错误

attendees = event['attendees'].get('email', event['attendees'].get('email'))
AttributeError: 'list' object has no attribute 'get'

这是代码

for event in events:

        start = event['start'].get('dateTime', event['start'].get('date'))
        end = event['end'].get('dateTime', event['end'].get('date'))
        attendees = event['attendees'].get('email', event['attendees'].get('email'))
        print(attendees)

【问题讨论】:

    标签: python google-api google-calendar-api google-api-python-client


    【解决方案1】:

    你不能在我猜是event['attendees'] 的列表上调用get()。您有多种处理方式。您可以循环访问event['attendees'] 并从每个与会者那里获取电子邮件。你也可以使用 map() 来做同样的事情

    forEach 循环示例:

    event['attendees'].forEach(attendee => console.log(attendee.get('email')))
    

    地图示例:

    const attendees = event['attendees'].map(attendee => attendee.get('email'))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-11-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多