python calendar.HTMLCalendar

前端 未结 5 1091
面向向阳花
面向向阳花 2021-02-02 04:10

I think I want to use pythons built in calendar module to create an HTML calendar with data. I say I think because I\'ll probably think of a better way, but right now it\'s a l

5条回答
  •  半阙折子戏
    2021-02-02 04:42

    Create a new class inheriting from HTMLCalendar. Override the formatday method.

    Whoever makes comments like "this library is useless" obviously doesn't understand Python.

    class EmployeeScheduleCalendar(HTMLCalendar):
        def formatday(self, day, weekday):
            """
              Return a day as a table cell.
            """
            if day == 0:
                return ' ' # day outside month
            else:
                return '%d' % (self.cssclasses[weekday], weekday, day)
    

提交回复
热议问题