赞
踩
Python 日期和时间
1,time.clock( )
2e-07
2,time.localtime([secs])
time.struct_time(tm_year=2021, tm_mon=4, tm_mday=21, tm_hour=16, tm_min=55, tm_sec=3)
3,time.sleep(secs)
延时,秒
4,time.strftime(fmt[,tupletime])
time.strftime("%Y %m %d",time.localtime()) 2021 04 21
5,time.time( )
时间戳
日历(Calendar)模块
1,print(calendar.calendar(2021,w=2,l=1,c=6))
2,calendar.isleap(year)
是闰年返回 True,否则为 False
3,calendar.leapdays(y1,y2)
返回在Y1,Y2两年之间的闰年总数
4,calendar.monthcalendar(year,month)
列表月和子列表星期表示
5,calendar.weekday(year,month,day)
判断星期几-1,
datetime 模块
print(datetime.datetime.now())
print(datetime.date.today())
print(datetime.date.today().strftime(’%d/%m/%Y’))
t1=datetime.date(2021,4,26) 创建日期
print(t1)
t2=t1-datetime.timedelta(days=1) 计算日期
print(t2)
t3=t2.replace(year=t2.year+1) 替代日期
print(t3)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。