Python 日历库calendar常用函数

简介: Python 日历库calendar常用函数

module calendar

>>> import calendar
>>> dir(calendar)
['Calendar', 'EPOCH', 'FRIDAY', 'February', 'HTMLCalendar', 'IllegalMonthError', 
'IllegalWeekdayError', 'January', 'LocaleHTMLCalendar', 'LocaleTextCalendar', 'MONDAY', 
'SATURDAY', 'SUNDAY', 'THURSDAY', 'TUESDAY', 'TextCalendar', 'WEDNESDAY', '_EPOCH_ORD', 
'__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', 
'__package__', '__spec__', '_colwidth', '_locale', '_localized_day', '_localized_month', 
'_monthlen', '_nextmonth', '_prevmonth', '_spacing', 'c', 'calendar', 'datetime', 
'day_abbr', 'day_name', 'different_locale', 'error', 'firstweekday', 'format', 
'formatstring', 'isleap', 'leapdays', 'main', 'mdays', 'month', 'month_abbr', 'month_name', 
'monthcalendar', 'monthrange', 'prcal', 'prmonth', 'prweek', 'repeat', 'setfirstweekday', 
'sys', 'timegm', 'week', 'weekday', 'weekheader']
>>> calendar.__all__
['IllegalMonthError', 'IllegalWeekdayError', 'setfirstweekday', 'firstweekday', 'isleap', 
'leapdays', 'weekday', 'monthrange', 'monthcalendar', 'prmonth', 'month', 'prcal', 
'calendar', 'timegm', 'month_name', 'month_abbr', 'day_name', 'day_abbr', 'Calendar', 
'TextCalendar', 'HTMLCalendar', 'LocaleTextCalendar', 'LocaleHTMLCalendar', 'weekheader']
>>> [i for i in dir(calendar) if i[0]>='a']
['c', 'calendar', 'datetime', 'day_abbr', 'day_name', 'different_locale', 'error', 
'firstweekday', 'format', 'formatstring', 'isleap', 'leapdays', 'main', 'mdays', 'month', 
'month_abbr', 'month_name', 'monthcalendar', 'monthrange', 'prcal', 'prmonth', 'prweek', 
'repeat', 'setfirstweekday', 'sys', 'timegm', 'week', 'weekday', 'weekheader']
>>> 


>>> help(calendar)
Help on module calendar:
NAME
    calendar - Calendar printing functions
MODULE REFERENCE
    https://docs.python.org/3.8/library/calendar
    The following documentation is automatically generated from the Python
    source files.  It may be incomplete, incorrect or include features that
    are considered implementation detail and may vary between Python
    implementations.  When in doubt, consult the module reference at the
    location listed above.
DESCRIPTION
    Note when comparing these calendars to the ones printed by cal(1): By
    default, these calendars have Monday as the first day of the week, and
    Sunday as the last (the European convention). Use setfirstweekday() to
    set the first day of the week (0=Monday, 6=Sunday).
CLASSES
    builtins.ValueError(builtins.Exception)
        IllegalMonthError
        IllegalWeekdayError
    builtins.object
        Calendar
            HTMLCalendar
                LocaleHTMLCalendar
            TextCalendar
                LocaleTextCalendar
    class Calendar(builtins.object)
     |  Calendar(firstweekday=0)
     |  
     |  Base calendar class. This class doesn't do any formatting. It simply
     |  provides data to subclasses.
     |  
     |  Methods defined here:
     |  
     |  __init__(self, firstweekday=0)
     |      Initialize self.  See help(type(self)) for accurate signature.
     |  
     |  getfirstweekday(self)
     |  
     |  itermonthdates(self, year, month)
     |      Return an iterator for one month. The iterator will yield datetime.date
     |      values and will always iterate through complete weeks, so it will yield
     |      dates outside the specified month.
     |  
     |  itermonthdays(self, year, month)
     |      Like itermonthdates(), but will yield day numbers. For days outside
     |      the specified month the day number is 0.
     |  
     |  itermonthdays2(self, year, month)
     |      Like itermonthdates(), but will yield (day number, weekday number)
     |      tuples. For days outside the specified month the day number is 0.
     |  
     |  itermonthdays3(self, year, month)
     |      Like itermonthdates(), but will yield (year, month, day) tuples.  Can be
     |      used for dates outside of datetime.date range.
     |  
     |  itermonthdays4(self, year, month)
     |      Like itermonthdates(), but will yield (year, month, day, day_of_week) tuples.
     |      Can be used for dates outside of datetime.date range.
     |  
     |  iterweekdays(self)
     |      Return an iterator for one week of weekday numbers starting with the
     |      configured first one.
     |  
     |  monthdatescalendar(self, year, month)
     |      Return a matrix (list of lists) representing a month's calendar.
     |      Each row represents a week; week entries are datetime.date values.
     |  
     |  monthdays2calendar(self, year, month)
     |      Return a matrix representing a month's calendar.
     |      Each row represents a week; week entries are
     |      (day number, weekday number) tuples. Day numbers outside this month
     |      are zero.
     |  
     |  monthdayscalendar(self, year, month)
     |      Return a matrix representing a month's calendar.
     |      Each row represents a week; days outside this month are zero.
     |  
     |  setfirstweekday(self, firstweekday)
     |  
     |  yeardatescalendar(self, year, width=3)
     |      Return the data for the specified year ready for formatting. The return
     |      value is a list of month rows. Each month row contains up to width months.
     |      Each month contains between 4 and 6 weeks and each week contains 1-7
     |      days. Days are datetime.date objects.
     |  
     |  yeardays2calendar(self, year, width=3)
     |      Return the data for the specified year ready for formatting (similar to
     |      yeardatescalendar()). Entries in the week lists are
     |      (day number, weekday number) tuples. Day numbers outside this month are
     |      zero.
     |  
     |  yeardayscalendar(self, year, width=3)
     |      Return the data for the specified year ready for formatting (similar to
     |      yeardatescalendar()). Entries in the week lists are day numbers.
     |      Day numbers outside this month are zero.
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |  
     |  __dict__
     |      dictionary for instance variables (if defined)
     |  
     |  __weakref__
     |      list of weak references to the object (if defined)
     |  
     |  firstweekday
    class HTMLCalendar(Calendar)
     |  HTMLCalendar(firstweekday=0)
     |  
     |  This calendar returns complete HTML pages.
     |  
     |  Method resolution order:
     |      HTMLCalendar
     |      Calendar
     |      builtins.object
     |  
     |  Methods defined here:
     |  
     |  formatday(self, day, weekday)
     |      Return a day as a table cell.
     |  
     |  formatmonth(self, theyear, themonth, withyear=True)
     |      Return a formatted month as a table.
     |  
     |  formatmonthname(self, theyear, themonth, withyear=True)
     |      Return a month name as a table row.
     |  
     |  formatweek(self, theweek)
     |      Return a complete week as a table row.
     |  
     |  formatweekday(self, day)
     |      Return a weekday name as a table header.
     |  
     |  formatweekheader(self)
     |      Return a header for a week as a table row.
     |  
     |  formatyear(self, theyear, width=3)
     |      Return a formatted year as a table of tables.
     |  
     |  formatyearpage(self, theyear, width=3, css='calendar.css', encoding=None)
     |      Return a formatted year as a complete HTML page.
     |  
     |  ----------------------------------------------------------------------
     |  Data and other attributes defined here:
     |  
     |  cssclass_month = 'month'
     |  
     |  cssclass_month_head = 'month'
     |  
     |  cssclass_noday = 'noday'
     |  
     |  cssclass_year = 'year'
     |  
     |  cssclass_year_head = 'year'
     |  
     |  cssclasses = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']
     |  
     |  cssclasses_weekday_head = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', '...
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from Calendar:
     |  
     |  __init__(self, firstweekday=0)
     |      Initialize self.  See help(type(self)) for accurate signature.
     |  
     |  getfirstweekday(self)
     |  
     |  itermonthdates(self, year, month)
     |      Return an iterator for one month. The iterator will yield datetime.date
     |      values and will always iterate through complete weeks, so it will yield
     |      dates outside the specified month.
     |  
     |  itermonthdays(self, year, month)
     |      Like itermonthdates(), but will yield day numbers. For days outside
     |      the specified month the day number is 0.
     |  
     |  itermonthdays2(self, year, month)
     |      Like itermonthdates(), but will yield (day number, weekday number)
     |      tuples. For days outside the specified month the day number is 0.
     |  
     |  itermonthdays3(self, year, month)
     |      Like itermonthdates(), but will yield (year, month, day) tuples.  Can be
     |      used for dates outside of datetime.date range.
     |  
     |  itermonthdays4(self, year, month)
     |      Like itermonthdates(), but will yield (year, month, day, day_of_week) tuples.
     |      Can be used for dates outside of datetime.date range.
     |  
     |  iterweekdays(self)
     |      Return an iterator for one week of weekday numbers starting with the
     |      configured first one.
     |  
     |  monthdatescalendar(self, year, month)
     |      Return a matrix (list of lists) representing a month's calendar.
     |      Each row represents a week; week entries are datetime.date values.
     |  
     |  monthdays2calendar(self, year, month)
     |      Return a matrix representing a month's calendar.
     |      Each row represents a week; week entries are
     |      (day number, weekday number) tuples. Day numbers outside this month
     |      are zero.
     |  
     |  monthdayscalendar(self, year, month)
     |      Return a matrix representing a month's calendar.
     |      Each row represents a week; days outside this month are zero.
     |  
     |  setfirstweekday(self, firstweekday)
     |  
     |  yeardatescalendar(self, year, width=3)
     |      Return the data for the specified year ready for formatting. The return
     |      value is a list of month rows. Each month row contains up to width months.
     |      Each month contains between 4 and 6 weeks and each week contains 1-7
     |      days. Days are datetime.date objects.
     |  
     |  yeardays2calendar(self, year, width=3)
     |      Return the data for the specified year ready for formatting (similar to
     |      yeardatescalendar()). Entries in the week lists are
     |      (day number, weekday number) tuples. Day numbers outside this month are
     |      zero.
     |  
     |  yeardayscalendar(self, year, width=3)
     |      Return the data for the specified year ready for formatting (similar to
     |      yeardatescalendar()). Entries in the week lists are day numbers.
     |      Day numbers outside this month are zero.
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from Calendar:
     |  
     |  __dict__
     |      dictionary for instance variables (if defined)
     |  
     |  __weakref__
     |      list of weak references to the object (if defined)
     |  
     |  firstweekday
    class IllegalMonthError(builtins.ValueError)
     |  IllegalMonthError(month)
     |  
     |  Inappropriate argument value (of correct type).
     |  
     |  Method resolution order:
     |      IllegalMonthError
     |      builtins.ValueError
     |      builtins.Exception
     |      builtins.BaseException
     |      builtins.object
     |  
     |  Methods defined here:
     |  
     |  __init__(self, month)
     |      Initialize self.  See help(type(self)) for accurate signature.
     |  
     |  __str__(self)
     |      Return str(self).
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |  
     |  __weakref__
     |      list of weak references to the object (if defined)
     |  
     |  ----------------------------------------------------------------------
     |  Static methods inherited from builtins.ValueError:
     |  
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from builtins.BaseException:
     |  
     |  __delattr__(self, name, /)
     |      Implement delattr(self, name).
     |  
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |  
     |  __reduce__(...)
     |      Helper for pickle.
     |  
     |  __repr__(self, /)
     |      Return repr(self).
     |  
     |  __setattr__(self, name, value, /)
     |      Implement setattr(self, name, value).
     |  
     |  __setstate__(...)
     |  
     |  with_traceback(...)
     |      Exception.with_traceback(tb) --
     |      set self.__traceback__ to tb and return self.
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from builtins.BaseException:
     |  
     |  __cause__
     |      exception cause
     |  
     |  __context__
     |      exception context
     |  
     |  __dict__
     |  
     |  __suppress_context__
     |  
     |  __traceback__
     |  
     |  args
    class IllegalWeekdayError(builtins.ValueError)
     |  IllegalWeekdayError(weekday)
     |  
     |  Inappropriate argument value (of correct type).
     |  
     |  Method resolution order:
     |      IllegalWeekdayError
     |      builtins.ValueError
     |      builtins.Exception
     |      builtins.BaseException
     |      builtins.object
     |  
     |  Methods defined here:
     |  
     |  __init__(self, weekday)
     |      Initialize self.  See help(type(self)) for accurate signature.
     |  
     |  __str__(self)
     |      Return str(self).
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors defined here:
     |  
     |  __weakref__
     |      list of weak references to the object (if defined)
     |  
     |  ----------------------------------------------------------------------
     |  Static methods inherited from builtins.ValueError:
     |  
     |  __new__(*args, **kwargs) from builtins.type
     |      Create and return a new object.  See help(type) for accurate signature.
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from builtins.BaseException:
     |  
     |  __delattr__(self, name, /)
     |      Implement delattr(self, name).
     |  
     |  __getattribute__(self, name, /)
     |      Return getattr(self, name).
     |  
     |  __reduce__(...)
     |      Helper for pickle.
     |  
     |  __repr__(self, /)
     |      Return repr(self).
     |  
     |  __setattr__(self, name, value, /)
     |      Implement setattr(self, name, value).
     |  
     |  __setstate__(...)
     |  
     |  with_traceback(...)
     |      Exception.with_traceback(tb) --
     |      set self.__traceback__ to tb and return self.
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from builtins.BaseException:
     |  
     |  __cause__
     |      exception cause
     |  
     |  __context__
     |      exception context
     |  
     |  __dict__
     |  
     |  __suppress_context__
     |  
     |  __traceback__
     |  
     |  args
    class LocaleHTMLCalendar(HTMLCalendar)
     |  LocaleHTMLCalendar(firstweekday=0, locale=None)
     |  
     |  This class can be passed a locale name in the constructor and will return
     |  month and weekday names in the specified locale. If this locale includes
     |  an encoding all strings containing month and weekday names will be returned
     |  as unicode.
     |  
     |  Method resolution order:
     |      LocaleHTMLCalendar
     |      HTMLCalendar
     |      Calendar
     |      builtins.object
     |  
     |  Methods defined here:
     |  
     |  __init__(self, firstweekday=0, locale=None)
     |      Initialize self.  See help(type(self)) for accurate signature.
     |  
     |  formatmonthname(self, theyear, themonth, withyear=True)
     |      Return a month name as a table row.
     |  
     |  formatweekday(self, day)
     |      Return a weekday name as a table header.
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from HTMLCalendar:
     |  
     |  formatday(self, day, weekday)
     |      Return a day as a table cell.
     |  
     |  formatmonth(self, theyear, themonth, withyear=True)
     |      Return a formatted month as a table.
     |  
     |  formatweek(self, theweek)
     |      Return a complete week as a table row.
     |  
     |  formatweekheader(self)
     |      Return a header for a week as a table row.
     |  
     |  formatyear(self, theyear, width=3)
     |      Return a formatted year as a table of tables.
     |  
     |  formatyearpage(self, theyear, width=3, css='calendar.css', encoding=None)
     |      Return a formatted year as a complete HTML page.
     |  
     |  ----------------------------------------------------------------------
     |  Data and other attributes inherited from HTMLCalendar:
     |  
     |  cssclass_month = 'month'
     |  
     |  cssclass_month_head = 'month'
     |  
     |  cssclass_noday = 'noday'
     |  
     |  cssclass_year = 'year'
     |  
     |  cssclass_year_head = 'year'
     |  
     |  cssclasses = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']
     |  
     |  cssclasses_weekday_head = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', '...
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from Calendar:
     |  
     |  getfirstweekday(self)
     |  
     |  itermonthdates(self, year, month)
     |      Return an iterator for one month. The iterator will yield datetime.date
     |      values and will always iterate through complete weeks, so it will yield
     |      dates outside the specified month.
     |  
     |  itermonthdays(self, year, month)
     |      Like itermonthdates(), but will yield day numbers. For days outside
     |      the specified month the day number is 0.
     |  
     |  itermonthdays2(self, year, month)
     |      Like itermonthdates(), but will yield (day number, weekday number)
     |      tuples. For days outside the specified month the day number is 0.
     |  
     |  itermonthdays3(self, year, month)
     |      Like itermonthdates(), but will yield (year, month, day) tuples.  Can be
     |      used for dates outside of datetime.date range.
     |  
     |  itermonthdays4(self, year, month)
     |      Like itermonthdates(), but will yield (year, month, day, day_of_week) tuples.
     |      Can be used for dates outside of datetime.date range.
     |  
     |  iterweekdays(self)
     |      Return an iterator for one week of weekday numbers starting with the
     |      configured first one.
     |  
     |  monthdatescalendar(self, year, month)
     |      Return a matrix (list of lists) representing a month's calendar.
     |      Each row represents a week; week entries are datetime.date values.
     |  
     |  monthdays2calendar(self, year, month)
     |      Return a matrix representing a month's calendar.
     |      Each row represents a week; week entries are
     |      (day number, weekday number) tuples. Day numbers outside this month
     |      are zero.
     |  
     |  monthdayscalendar(self, year, month)
     |      Return a matrix representing a month's calendar.
     |      Each row represents a week; days outside this month are zero.
     |  
     |  setfirstweekday(self, firstweekday)
     |  
     |  yeardatescalendar(self, year, width=3)
     |      Return the data for the specified year ready for formatting. The return
     |      value is a list of month rows. Each month row contains up to width months.
     |      Each month contains between 4 and 6 weeks and each week contains 1-7
     |      days. Days are datetime.date objects.
     |  
     |  yeardays2calendar(self, year, width=3)
     |      Return the data for the specified year ready for formatting (similar to
     |      yeardatescalendar()). Entries in the week lists are
     |      (day number, weekday number) tuples. Day numbers outside this month are
     |      zero.
     |  
     |  yeardayscalendar(self, year, width=3)
     |      Return the data for the specified year ready for formatting (similar to
     |      yeardatescalendar()). Entries in the week lists are day numbers.
     |      Day numbers outside this month are zero.
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from Calendar:
     |  
     |  __dict__
     |      dictionary for instance variables (if defined)
     |  
     |  __weakref__
     |      list of weak references to the object (if defined)
     |  
     |  firstweekday
    class LocaleTextCalendar(TextCalendar)
     |  LocaleTextCalendar(firstweekday=0, locale=None)
     |  
     |  This class can be passed a locale name in the constructor and will return
     |  month and weekday names in the specified locale. If this locale includes
     |  an encoding all strings containing month and weekday names will be returned
     |  as unicode.
     |  
     |  Method resolution order:
     |      LocaleTextCalendar
     |      TextCalendar
     |      Calendar
     |      builtins.object
     |  
     |  Methods defined here:
     |  
     |  __init__(self, firstweekday=0, locale=None)
     |      Initialize self.  See help(type(self)) for accurate signature.
     |  
     |  formatmonthname(self, theyear, themonth, width, withyear=True)
     |      Return a formatted month name.
     |  
     |  formatweekday(self, day, width)
     |      Returns a formatted week day name.
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from TextCalendar:
     |  
     |  formatday(self, day, weekday, width)
     |      Returns a formatted day.
     |  
     |  formatmonth(self, theyear, themonth, w=0, l=0)
     |      Return a month's calendar string (multi-line).
     |  
     |  formatweek(self, theweek, width)
     |      Returns a single week in a string (no newline).
     |  
     |  formatweekheader(self, width)
     |      Return a header for a week.
     |  
     |  formatyear(self, theyear, w=2, l=1, c=6, m=3)
     |      Returns a year's calendar as a multi-line string.
     |  
     |  prmonth(self, theyear, themonth, w=0, l=0)
     |      Print a month's calendar.
     |  
     |  prweek(self, theweek, width)
     |      Print a single week (no newline).
     |  
     |  pryear(self, theyear, w=0, l=0, c=6, m=3)
     |      Print a year's calendar.
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from Calendar:
     |  
     |  getfirstweekday(self)
     |  
     |  itermonthdates(self, year, month)
     |      Return an iterator for one month. The iterator will yield datetime.date
     |      values and will always iterate through complete weeks, so it will yield
     |      dates outside the specified month.
     |  
     |  itermonthdays(self, year, month)
     |      Like itermonthdates(), but will yield day numbers. For days outside
     |      the specified month the day number is 0.
     |  
     |  itermonthdays2(self, year, month)
     |      Like itermonthdates(), but will yield (day number, weekday number)
     |      tuples. For days outside the specified month the day number is 0.
     |  
     |  itermonthdays3(self, year, month)
     |      Like itermonthdates(), but will yield (year, month, day) tuples.  Can be
     |      used for dates outside of datetime.date range.
     |  
     |  itermonthdays4(self, year, month)
     |      Like itermonthdates(), but will yield (year, month, day, day_of_week) tuples.
     |      Can be used for dates outside of datetime.date range.
     |  
     |  iterweekdays(self)
     |      Return an iterator for one week of weekday numbers starting with the
     |      configured first one.
     |  
     |  monthdatescalendar(self, year, month)
     |      Return a matrix (list of lists) representing a month's calendar.
     |      Each row represents a week; week entries are datetime.date values.
     |  
     |  monthdays2calendar(self, year, month)
     |      Return a matrix representing a month's calendar.
     |      Each row represents a week; week entries are
     |      (day number, weekday number) tuples. Day numbers outside this month
     |      are zero.
     |  
     |  monthdayscalendar(self, year, month)
     |      Return a matrix representing a month's calendar.
     |      Each row represents a week; days outside this month are zero.
     |  
     |  setfirstweekday(self, firstweekday)
     |  
     |  yeardatescalendar(self, year, width=3)
     |      Return the data for the specified year ready for formatting. The return
     |      value is a list of month rows. Each month row contains up to width months.
     |      Each month contains between 4 and 6 weeks and each week contains 1-7
     |      days. Days are datetime.date objects.
     |  
     |  yeardays2calendar(self, year, width=3)
     |      Return the data for the specified year ready for formatting (similar to
     |      yeardatescalendar()). Entries in the week lists are
     |      (day number, weekday number) tuples. Day numbers outside this month are
     |      zero.
     |  
     |  yeardayscalendar(self, year, width=3)
     |      Return the data for the specified year ready for formatting (similar to
     |      yeardatescalendar()). Entries in the week lists are day numbers.
     |      Day numbers outside this month are zero.
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from Calendar:
     |  
     |  __dict__
     |      dictionary for instance variables (if defined)
     |  
     |  __weakref__
     |      list of weak references to the object (if defined)
     |  
     |  firstweekday
    class TextCalendar(Calendar)
     |  TextCalendar(firstweekday=0)
     |  
     |  Subclass of Calendar that outputs a calendar as a simple plain text
     |  similar to the UNIX program cal.
     |  
     |  Method resolution order:
     |      TextCalendar
     |      Calendar
     |      builtins.object
     |  
     |  Methods defined here:
     |  
     |  formatday(self, day, weekday, width)
     |      Returns a formatted day.
     |  
     |  formatmonth(self, theyear, themonth, w=0, l=0)
     |      Return a month's calendar string (multi-line).
     |  
     |  formatmonthname(self, theyear, themonth, width, withyear=True)
     |      Return a formatted month name.
     |  
     |  formatweek(self, theweek, width)
     |      Returns a single week in a string (no newline).
     |  
     |  formatweekday(self, day, width)
     |      Returns a formatted week day name.
     |  
     |  formatweekheader(self, width)
     |      Return a header for a week.
     |  
     |  formatyear(self, theyear, w=2, l=1, c=6, m=3)
     |      Returns a year's calendar as a multi-line string.
     |  
     |  prmonth(self, theyear, themonth, w=0, l=0)
     |      Print a month's calendar.
     |  
     |  prweek(self, theweek, width)
     |      Print a single week (no newline).
     |  
     |  pryear(self, theyear, w=0, l=0, c=6, m=3)
     |      Print a year's calendar.
     |  
     |  ----------------------------------------------------------------------
     |  Methods inherited from Calendar:
     |  
     |  __init__(self, firstweekday=0)
     |      Initialize self.  See help(type(self)) for accurate signature.
     |  
     |  getfirstweekday(self)
     |  
     |  itermonthdates(self, year, month)
     |      Return an iterator for one month. The iterator will yield datetime.date
     |      values and will always iterate through complete weeks, so it will yield
     |      dates outside the specified month.
     |  
     |  itermonthdays(self, year, month)
     |      Like itermonthdates(), but will yield day numbers. For days outside
     |      the specified month the day number is 0.
     |  
     |  itermonthdays2(self, year, month)
     |      Like itermonthdates(), but will yield (day number, weekday number)
     |      tuples. For days outside the specified month the day number is 0.
     |  
     |  itermonthdays3(self, year, month)
     |      Like itermonthdates(), but will yield (year, month, day) tuples.  Can be
     |      used for dates outside of datetime.date range.
     |  
     |  itermonthdays4(self, year, month)
     |      Like itermonthdates(), but will yield (year, month, day, day_of_week) tuples.
     |      Can be used for dates outside of datetime.date range.
     |  
     |  iterweekdays(self)
     |      Return an iterator for one week of weekday numbers starting with the
     |      configured first one.
     |  
     |  monthdatescalendar(self, year, month)
     |      Return a matrix (list of lists) representing a month's calendar.
     |      Each row represents a week; week entries are datetime.date values.
     |  
     |  monthdays2calendar(self, year, month)
     |      Return a matrix representing a month's calendar.
     |      Each row represents a week; week entries are
     |      (day number, weekday number) tuples. Day numbers outside this month
     |      are zero.
     |  
     |  monthdayscalendar(self, year, month)
     |      Return a matrix representing a month's calendar.
     |      Each row represents a week; days outside this month are zero.
     |  
     |  setfirstweekday(self, firstweekday)
     |  
     |  yeardatescalendar(self, year, width=3)
     |      Return the data for the specified year ready for formatting. The return
     |      value is a list of month rows. Each month row contains up to width months.
     |      Each month contains between 4 and 6 weeks and each week contains 1-7
     |      days. Days are datetime.date objects.
     |  
     |  yeardays2calendar(self, year, width=3)
     |      Return the data for the specified year ready for formatting (similar to
     |      yeardatescalendar()). Entries in the week lists are
     |      (day number, weekday number) tuples. Day numbers outside this month are
     |      zero.
     |  
     |  yeardayscalendar(self, year, width=3)
     |      Return the data for the specified year ready for formatting (similar to
     |      yeardatescalendar()). Entries in the week lists are day numbers.
     |      Day numbers outside this month are zero.
     |  
     |  ----------------------------------------------------------------------
     |  Data descriptors inherited from Calendar:
     |  
     |  __dict__
     |      dictionary for instance variables (if defined)
     |  
     |  __weakref__
     |      list of weak references to the object (if defined)
     |  
     |  firstweekday
FUNCTIONS
    calendar = formatyear(theyear, w=2, l=1, c=6, m=3) method of TextCalendar instance
        Returns a year's calendar as a multi-line string.
    firstweekday = getfirstweekday() method of TextCalendar instance
    isleap(year)
        Return True for leap years, False for non-leap years.
    leapdays(y1, y2)
        Return number of leap years in range [y1, y2).
        Assume y1 <= y2.
    month = formatmonth(theyear, themonth, w=0, l=0) method of TextCalendar instance
        Return a month's calendar string (multi-line).
    monthcalendar = monthdayscalendar(year, month) method of TextCalendar instance
        Return a matrix representing a month's calendar.
        Each row represents a week; days outside this month are zero.
    monthrange(year, month)
        Return weekday (0-6 ~ Mon-Sun) and number of days (28-31) for
        year, month.
    prcal = pryear(theyear, w=0, l=0, c=6, m=3) method of TextCalendar instance
        Print a year's calendar.
    prmonth(theyear, themonth, w=0, l=0) method of TextCalendar instance
        Print a month's calendar.
    setfirstweekday(firstweekday)
    timegm(tuple)
        Unrelated but handy function to calculate Unix timestamp from GMT.
    weekday(year, month, day)
        Return weekday (0-6 ~ Mon-Sun) for year, month (1-12), day (1-31).
    weekheader = formatweekheader(width) method of TextCalendar instance
        Return a header for a week.
DATA
    __all__ = ['IllegalMonthError', 'IllegalWeekdayError', 'setfirstweekda...
    day_abbr = <calendar._localized_day object>
    day_name = <calendar._localized_day object>
    month_abbr = <calendar._localized_month object>
    month_name = <calendar._localized_month object>
FILE
    d:\python38-32\lib\calendar.py
>>> 




目录
相关文章
|
10天前
|
调度 开发者 Python
Python中的异步编程:理解asyncio库
在Python的世界里,异步编程是一种高效处理I/O密集型任务的方法。本文将深入探讨Python的asyncio库,它是实现异步编程的核心。我们将从asyncio的基本概念出发,逐步解析事件循环、协程、任务和期货的概念,并通过实例展示如何使用asyncio来编写异步代码。不同于传统的同步编程,异步编程能够让程序在等待I/O操作完成时释放资源去处理其他任务,从而提高程序的整体效率和响应速度。
|
6天前
|
数据库 Python
异步编程不再难!Python asyncio库实战,让你的代码流畅如丝!
在编程中,随着应用复杂度的提升,对并发和异步处理的需求日益增长。Python的asyncio库通过async和await关键字,简化了异步编程,使其变得流畅高效。本文将通过实战示例,介绍异步编程的基本概念、如何使用asyncio编写异步代码以及处理多个异步任务的方法,帮助你掌握异步编程技巧,提高代码性能。
20 4
|
6天前
|
API 数据处理 Python
探秘Python并发新世界:asyncio库,让你的代码并发更优雅!
在Python编程中,随着网络应用和数据处理需求的增长,并发编程变得愈发重要。asyncio库作为Python 3.4及以上版本的标准库,以其简洁的API和强大的异步编程能力,成为提升性能和优化资源利用的关键工具。本文介绍了asyncio的基本概念、异步函数的定义与使用、并发控制和资源管理等核心功能,通过具体示例展示了如何高效地编写并发代码。
15 2
|
12天前
|
数据采集 JSON 测试技术
Python爬虫神器requests库的使用
在现代编程中,网络请求是必不可少的部分。本文详细介绍 Python 的 requests 库,一个功能强大且易用的 HTTP 请求库。内容涵盖安装、基本功能(如发送 GET 和 POST 请求、设置请求头、处理响应)、高级功能(如会话管理和文件上传)以及实际应用场景。通过本文,你将全面掌握 requests 库的使用方法。🚀🌟
33 7
|
12天前
|
机器学习/深度学习 数据采集 算法
Python机器学习:Scikit-learn库的高效使用技巧
【10月更文挑战第28天】Scikit-learn 是 Python 中最受欢迎的机器学习库之一,以其简洁的 API、丰富的算法和良好的文档支持而受到开发者喜爱。本文介绍了 Scikit-learn 的高效使用技巧,包括数据预处理(如使用 Pipeline 和 ColumnTransformer)、模型选择与评估(如交叉验证和 GridSearchCV)以及模型持久化(如使用 joblib)。通过这些技巧,你可以在机器学习项目中事半功倍。
20 3
|
5天前
|
数据采集 数据可视化 数据挖掘
利用Python进行数据分析:Pandas库实战指南
利用Python进行数据分析:Pandas库实战指南
|
12天前
|
文字识别 自然语言处理 API
Python中的文字识别利器:pytesseract库
`pytesseract` 是一个基于 Google Tesseract-OCR 引擎的 Python 库,能够从图像中提取文字,支持多种语言,易于使用且兼容性强。本文介绍了 `pytesseract` 的安装、基本功能、高级特性和实际应用场景,帮助读者快速掌握 OCR 技术。
29 0
|
6月前
|
算法 Python 容器
Python编程 - 不调用相关choose库函数,“众数“挑选器、随机挑选器 的源码编程实现
Python编程 - 不调用相关choose库函数,“众数“挑选器、随机挑选器 的源码编程实现
85 0
|
2月前
|
算法 Python
Python编程的函数—内置函数
Python编程的函数—内置函数
|
6月前
|
算法 Python
Python编程实验四:函数的使用
Python编程实验四:函数的使用
89 0