import time
# 获取当前时间戳:1522293257.81
t = time.time()
'''
加载为时间数组:
time.struct_time(tm_year=2018, tm_mon=3, tm_mday=29, tm_hour=11, tm_min=14, tm_sec=17, tm_wday=3, tm_yday=88, tm_isdst=0)
'''
t1 = time.localtime(t)
'''
格式化:2018-03-29 11:14:17
'''
t2 = time.strftime('%Y-%m-%d %H:%M:%S', t1)
'''
将时间格式转换成时间数组:
time.struct_time(tm_year=2018, tm_mon=3, tm_mday=29, tm_hour=11, tm_min=14, tm_sec=17, tm_wday=3, tm_yday=88, tm_isdst=-1)
'''
t3 = time.strptime(t2, "%Y-%m-%d %H:%M:%S")
'''
将时间数组转换成时间戳:1522293257.0
'''
t4 = time.mktime(t3)
print t
print t1
print t2
print t3
print t4