Python: Calendar (Calendar) module

This module functions are related to the calendar, such as printing a calendar month characters.
Monday is the default first day of the week, Sunday is the last day of default. Change the setting to be called calendar.setfirstweekday () function. Built-in module includes the following functions:
serial number and description of function
1 calendar.calendar (year, w = 2 , l = 1, c = 6)
returns in a multi-line calendar year string format, line 3 months, separated by a distance c. Daily interval width w characters. Each line length is 21 * W + 18 + 2 * C. l is the number of lines per week.
2 calendar.firstweekday ()
Returns the current set week start date. By default, when you first load caendar module returns 0, ie Monday.
3 calendar.isleap (year)
is a leap year returns True, otherwise false.

import calendar
print(calendar.isleap(2000))
True

Print (calendar.isleap (1900))
False
. 4 calendar.leapdays (Y1, Y2)
returns Y1, Y2 between the total number of leap years.
5 calendar.month (year, month, w = 2, l = 1)
Returns a string of multi-line format, year-month calendar month, two row headings week line. Daily interval width w characters. The length of each line is 7 * w + 6. l is the number of lines per week.
6 calendar.monthcalendar (year, month)
Returns a single nested lists integers. Each sub-list represents the integer load a week. Date Year outside of month to month is set to 0; day range by the first few days of the month, said from the beginning.
7 calendar.monthrange (year, month)
Returns the integer two. The first week of the month, the second is the month for a few days. Day of the week is from 0 (Monday) through 6 (Sunday).

Calendar Import
calendar.monthrange (2014, 11)
(5, 30)
(5, 30) explain: 5 for the first day of November 2014 is Saturday, 30 November 2014 represent a total of 30 days.
8 calendar.prcal (year, w = 2 , l = 1, c = 6)
corresponds calendar.calendar Print (year, W, L, C).
. 9 calendar.prmonth (year, month The, W = 2, L = 1)
corresponding to print calendar.calendar (year, w, l , c).
10 calendar.setfirstweekday (weekday)
setting week start date code. 0 (Monday) through 6 (Sunday).
11 calendar.timegm (tupletime)
and the opposite time.gmtime: accepting a time tuple form, the time stamp of the return time (epoch after 1970 seconds elapsed floating point).
12 calendar.weekday (year, month, day )
is returned to the given date date code. 0 (Monday) through 6 (Sunday). 1 month (January) to 12 (December).

Guess you like

Origin blog.csdn.net/weixin_44523387/article/details/93379341