from icalendar import Calendar ical_data = "BEGIN:VCALENDAR\n... (iCalendar data here) ...\nEND:VCALENDAR" cal = Calendar.from_string(ical_data)
from icalendar import Calendar with open("schedule.ics") as file: cal = Calendar.from_ical(file.read())Both of these examples demonstrate how to create a Calendar object using the from_string() method of Calendar class. The first example shows how to create the object directly from a string containing the iCalendar data, whereas the second shows how to create the object from a file on the local file system. The package library used here is icalendar.