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
>>> 




目录
相关文章
|
1天前
|
开发者 Python
Python入门:8.Python中的函数
### 引言 在编写程序时,函数是一种强大的工具。它们可以将代码逻辑模块化,减少重复代码的编写,并提高程序的可读性和可维护性。无论是初学者还是资深开发者,深入理解函数的使用和设计都是编写高质量代码的基础。本文将从基础概念开始,逐步讲解 Python 中的函数及其高级特性。
Python入门:8.Python中的函数
|
4天前
|
数据采集 JavaScript Android开发
【02】仿站技术之python技术,看完学会再也不用去购买收费工具了-本次找了小影-感觉页面很好看-本次是爬取vue需要用到Puppeteer库用node.js扒一个app下载落地页-包括安卓android下载(简单)-ios苹果plist下载(稍微麻烦一丢丢)-优雅草卓伊凡
【02】仿站技术之python技术,看完学会再也不用去购买收费工具了-本次找了小影-感觉页面很好看-本次是爬取vue需要用到Puppeteer库用node.js扒一个app下载落地页-包括安卓android下载(简单)-ios苹果plist下载(稍微麻烦一丢丢)-优雅草卓伊凡
29 7
【02】仿站技术之python技术,看完学会再也不用去购买收费工具了-本次找了小影-感觉页面很好看-本次是爬取vue需要用到Puppeteer库用node.js扒一个app下载落地页-包括安卓android下载(简单)-ios苹果plist下载(稍微麻烦一丢丢)-优雅草卓伊凡
|
28天前
|
测试技术 Python
【03】做一个精美的打飞机小游戏,规划游戏项目目录-分门别类所有的资源-库-类-逻辑-打包为可玩的exe-练习python打包为可执行exe-优雅草卓伊凡-持续更新-分享源代码和游戏包供游玩-1.0.2版本
【03】做一个精美的打飞机小游戏,规划游戏项目目录-分门别类所有的资源-库-类-逻辑-打包为可玩的exe-练习python打包为可执行exe-优雅草卓伊凡-持续更新-分享源代码和游戏包供游玩-1.0.2版本
106 31
【03】做一个精美的打飞机小游戏,规划游戏项目目录-分门别类所有的资源-库-类-逻辑-打包为可玩的exe-练习python打包为可执行exe-优雅草卓伊凡-持续更新-分享源代码和游戏包供游玩-1.0.2版本
|
1月前
|
存储 人工智能 Python
[oeasy]python061_如何接收输入_input函数_字符串_str_容器_ 输入输出
本文介绍了Python中如何使用`input()`函数接收用户输入。`input()`函数可以从标准输入流获取字符串,并将其赋值给变量。通过键盘输入的值可以实时赋予变量,实现动态输入。为了更好地理解其用法,文中通过实例演示了如何接收用户输入并存储在变量中,还介绍了`input()`函数的参数`prompt`,用于提供输入提示信息。最后总结了`input()`函数的核心功能及其应用场景。更多内容可参考蓝桥、GitHub和Gitee上的相关教程。
16 0
|
1月前
|
机器学习/深度学习 存储 数据挖掘
Python图像处理实用指南:PIL库的多样化应用
本文介绍Python中PIL库在图像处理中的多样化应用,涵盖裁剪、调整大小、旋转、模糊、锐化、亮度和对比度调整、翻转、压缩及添加滤镜等操作。通过具体代码示例,展示如何轻松实现这些功能,帮助读者掌握高效图像处理技术,适用于图片美化、数据分析及机器学习等领域。
73 20
|
1月前
|
Python
[oeasy]python057_如何删除print函数_dunder_builtins_系统内建模块
本文介绍了如何删除Python中的`print`函数,并探讨了系统内建模块`__builtins__`的作用。主要内容包括: 1. **回忆上次内容**:上次提到使用下划线避免命名冲突。 2. **双下划线变量**:解释了双下划线(如`__name__`、`__doc__`、`__builtins__`)是系统定义的标识符,具有特殊含义。
32 3
|
1月前
|
JSON 监控 安全
深入理解 Python 的 eval() 函数与空全局字典 {}
`eval()` 函数在 Python 中能将字符串解析为代码并执行,但伴随安全风险,尤其在处理不受信任的输入时。传递空全局字典 {} 可限制其访问内置对象,但仍存隐患。建议通过限制函数和变量、使用沙箱环境、避免复杂表达式、验证输入等提高安全性。更推荐使用 `ast.literal_eval()`、自定义解析器或 JSON 解析等替代方案,以确保代码安全性和可靠性。
45 2
|
2月前
|
数据可视化 DataX Python
Seaborn 教程-绘图函数
Seaborn 教程-绘图函数
87 8
|
2月前
|
XML JSON 数据库
Python的标准库
Python的标准库
185 77
|
9月前
|
Python
Python通过导入 calendar 模块来计算每个月的天
Python通过导入 calendar 模块来计算每个月的天

热门文章

最新文章

推荐镜像

更多