python语言:月历表制作

编程入门 行业动态 更新时间:2024-10-14 20:20:02

python语言:<a href=https://www.elefans.com/category/jswz/34/1725485.html style=月历表制作"/>

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语言:月历表制作

本文发布于:2024-03-09 16:25:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1725486.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:月历   语言   python

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!