Python定义了一个内置模块calendar
,用于处理与日历相关的操作。Calendar module
允许输出日历,如程序,并提供与日历相关的其他有用功能。Calendar模块中定义的函数和类使用理想化的日历,当前的公历在两个方向上无限延伸。默认情况下,这些日历将星期一作为一周的第一天,将星期日作为最后一天(欧洲惯例)。
示例#1:显示给定月份的日历
# Python program to display calendar of
# given month of the year
# import module
import calendar
yy = 2017
mm = 11
# display the calendar
print(calendar.month(yy, mm))
示例#2:显示给定年份的日历。
# Python code to demonstrate the working of
# calendar() function to print calendar
# importing calendar module
# for calendar operations
import calendar
# using calender to print calendar of year
# prints calendar of 2018
print ("The calender of year 2018 is : ")
print (calendar.calendar(2018, 2, 1, 6))








暂无数据