time time.sleep(5) time.time() # 获取当前时间戳(类型为float) 将时间戳转化成时间元组time.struct_time time.localtime() 返回当地时间下的时间元组t / time.gmtime() 转换为UTC时区(0时区)的struct_time  
time.mktime() 将struct_time元组转化成时间戳 
time.strftime() 把time.struct_time转换成string 例:n=time.strftime("%Y-%m-%d %H:%M:%S %A",t_1)  time.strptime(n,"%Y-%m-%d %H:%M:%S %A") #将字符串转化为time.struct_time 
datetime datetime.datetime.now() #获取当前时间 datetime.datetime.strptime(“2020-07-09 18:21:17”,"%Y-%m-%d %H:%M:%S" ) 将字符串转化成datatime.datatime。  datatime.datatime.now().strftime("%Y-%m-%d %H:%M:%S") 返回字符串 
|