Python3 标准库:calendar,time

1.calendar

import calendar

print(calendar.month(2008,8))	#某个月 print(calendar.calendar(2008)) #某年 print(calendar.isleap(2008)) #是否闰年 print(calendar.leapdays(1900,2008)) #两个年份之间存在几个闰年 print(calendar.monthcalendar(2008,8)) #返回周一到周日的列表 print(calendar.monthrange(2008,8)) #返回一个元组(4,31)代表该月从周五开始,共31天 print(calendar.weekday(2008,8,8)) #输入日期,返回周几

2.time

import time

print(time.time())	#输出当前时间戳
print(time.localtime())	#输出当前本地时间元组 print(time.ctime()) #输出当前时间,默认参数是当前时间戳 print(time.strftime('%y,%m,%d,%H,%M,%S')) #年月日时分秒 time.sleep(5) #睡眠5秒

猜你喜欢

转载自www.cnblogs.com/zmqqq/p/10506157.html