Python HTMLCalendar - formatyearpage()


Python tip:

Did you know you can generate a complete HTML page with a yearly calendar using Python?

import calendar
import tempfile
import webbrowser

cal = calendar.HTMLCalendar()
html_calendar = cal.formatyearpage(2022)


with tempfile.NamedTemporaryFile('w', delete=False, suffix='.html') as f:
    url = 'file://' + f.name
    f.write(html_calendar.decode())

webbrowser.open(url)