基本的示例如下:
import calendar
#获取某年日历
print(calendar.prcal(2020,m=4))
#calendar(year, w=2, l=1, c=6, m=3)以多行字符串形式返回一年的日历 w每个单元格宽度,默认2。l每列换l行,默认为1。c表示月与月之间的间隔宽度,默认为6。
print(calendar.calendar(2020, m=4))
#获取某月日历
print(calendar.month(2020,3))
#month(theyear, themonth, w=0, l=0):返回一个月的日历的多行文本字符串。
print(calendar.month(2019,12))
#setfirstweekday(firstweekday):指定一周的第一天,0是星期一,…,6为星期日
#firstweekday():返回一周的第一天,0是星期一,…,6为星期日
calendar.setfirstweekday(firstweekday=1)
print(calendar.firstweekday())
calendar.prmonth(2020,3) #prmonth(theyear, themonth, w=0, l=0):打印一个月的日历,theyear指定年份,themonth指定月份,w每个单元格宽度,默认0,内部已做处理,最小宽度为2,l每列换l行,默认为0,内部已做处理,至少换行1行
#isleap(year):判断指定是否是闰年,闰年为True,平年为False
print(calendar.isleap(2008))
#l