python: calendar

 

import calendar

    yy=int(input("请输入年份:"))
    calendar.setfirstweekday(firstweekday=0) #为了符合习惯,指定日历的第一天是星期一
    calendar.prcal(yy,w=0,l=0,c=0,m=4) #显示日历,c=0  为一周的第一天为星期一,与上面对应

  

结果:

    #倒计时
    nowtime=datetime.datetime.now()
    print("当前时间为:",nowtime)
    targetdate=input("输入时间以-分隔,例如:2023-7-8 23:10:10\n")
    target=datetime.datetime.strptime(targetdate,"%Y-%m-%d %H:%M:%S")
    print("目上标时间:",target)
    while True:
        nowtime=datetime.datetime.now()
        if target>nowtime:
            print("时间未到,当前时间为:",nowtime)
            time.sleep(1)

        else:
            print("时间已经到")
            break
    print("ok")

  

 

posted @ 2023-07-08 09:07  ®Geovin Du Dream Park™  阅读(66)  评论(0)    收藏  举报