日期和时间
from datetime import datetime, date now = datetime.now() now #datetime.datetime(2016, 8, 13, 23, 7, 47, 768757) print(now.strftime('%Y-%m-%d %H:%M:%S')) #2016-08-13 23:08:04
# 检测是否是闰年 import calendar print(calendar.isleap(1900)) #False print(calendar.isleap(1996)) #True # datetime模块 #date 处理年、月、日 #time 处理时、分、秒和分数 #datetime 处理日期和时间同时出现的情况 #timedelta 处理日期和/ 或时间间隔 from datetime import date halloween = date(2014, 10, 31) print(halloween.day) #31 print(halloween.month) #10 print(halloween.year) #2014 print(halloween.isoformat()) #'2014-10-31'