# 日期和时间---time模块
import time
# 获取当前时间戳(未格式化的)
t1 = time.time()
print(t1)
# 获取时间元组 (未格式化的)
t3 = time.localtime()
print(t3)
# 获取格式化的时间
t2 = time.ctime()
print(t2)
t4 = time.asctime()
print(t4)
# 自定义格式化时间
t5 = time.strftime('%Y/%m/%d %H:%M:%S', time.localtime())
print(t5)
t6 = time.strftime('%y/%m/%d %H:%M:%S', time.localtime())
print(t6)
# 转变为时间元组
t7 = time.strptime('2019/02/25 22:48:36', '%Y/%m/%d %H:%M:%S')
print(t7)
# 时间元组--->时间戳
t8 = time.mktime(t7)
print(t8)
# 休眠
print(11111111111)
time.sleep(3)
print(22222222222)
# 日期和时间----datetime模块
import datetime
time1 = datetime.datetime.today()
time2 = datetime.datetime.now()
print(time1)
print(time2)
print(time1.date())
print(time1.time())
print(time1.year)
print(time1.month)
print(time1.day)
print(time1.hour)
print(time1.minute)
print(time1.second)
print(time1.microsecond)
# 格式化时间
print(time1.ctime())
print(time1.strftime('%Y-%m-%d %H:%M:%S'))
print(time1.strftime('%H:%M:%S'))
# 计算N天之后的日期时间
import datetime
t = datetime.datetime.today()
print(t)
res = t + datetime.timedelta(days=7)
print(res)