python: calendar

 

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

  

结果:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#倒计时
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 @   ®Geovin Du Dream Park™  阅读(12)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
历史上的今天:
2014-07-08 csharp: QR Code Barcode
2011-07-08 sql server 2005 输出表的函數用法
2011-07-08 SQL server 2005 表中某一字段的所有值逗号分开的列表
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示