月历表制作"/>
python语言:月历表制作
月历表代码制作如下:
#显示给定年份的日历
#打印日历函数
def printMonth(year,month):
printMonthTitle(year,month)
printMonthBody(year,month)
#打印标题栏显示月份与年份
def printMonthTitle(year,month):
print(" ",getMonthName(month)," ",year)
print("---------------------------------------")
print(" sun Mon Tue Wed Thu Fri Sat")
#打印日历主体
def printMonthBody(year,month):
startDay=getStartDay(year,month)
numberOfDaysInMonth=getNumberOfDaysInMonth(year,month)
i=0
for i in range(0,startDay):
print(" ",end=" ")
for i in range(1,numberOfDaysInMonth+1):
print(format(i,"4d"),end=" ")
if (i+startDay)%7==0:
print()
def getMonthName(month):
if month==1:
monthName="Ja
更多推荐
python语言:月历表制作
发布评论