我遵循了https://pythonhosted.org/caldav/的快速入门指南,但这个错误(谷歌不知道)总是出现。有什么想法吗?
堆栈跟踪:

client = caldav.DAVClient(url='https://caldav.yandex.ru/', username='username', password='password')
my_principal = client.principal()
calendars = my_principal.calendars()
vcal = """BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Example Corp.//CalDAV Client//EN
BEGIN:VEVENT
UID:1234567890
DTSTAMP:20100510T182145Z
DTSTART:20100512T170000Z
DTEND:20100512T180000Z
SUMMARY:This is an event
END:VEVENT
END:VCALENDAR
"""
calendars[0]s.save_event(vcal)发布于 2021-03-15 21:05:00
我还看到其他几个人也有同样的问题。上面的vcal字符串包含前导空格,这违反了icalendar标准,vobject库将拒绝它。
python-caldav库的最新版本0.8.0中的错误处理进行了一些更改,以便更好地指示icalendar数据可能已损坏。
你可以这样写它,它看起来有点丑陋,但它会工作的:
vcal = """BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Example Corp.//CalDAV Client//EN
BEGIN:VEVENT
UID:1234567890
DTSTAMP:20100510T182145Z
DTSTART:20100512T170000Z
DTEND:20100512T180000Z
SUMMARY:This is an event
END:VEVENT
END:VCALENDAR
"""https://stackoverflow.com/questions/65061962
复制相似问题