import time #时间戳 #计算 print(time.time()) #1591259157.4499538秒 #结构化时间---当地时间 print(time.localtime(1531242343)) t=time.localtime() print(t.tm_year) print(t.tm_wday) #time.struct_time(tm_year=2018, tm_mon=7, tm_mday=11, tm_hour=1, tm_min=5, tm_sec=43, tm_wday=2, tm_yday=192, tm_isdst=0) #2020 #3 # #-----#结构化时间---UTC print(time.gmtime())#time.struct_time(tm_year=2020, tm_mon=6, tm_mday=4, tm_hour=8, tm_min=25, tm_sec=57, tm_wday=3, tm_yday=156, tm_isdst=0) #-----将结构化时间转换成时间戳 print(time.mktime(time.localtime()))#1591259157.0 #------将结构化时间转成字符串时间strftime print(time.strftime("%Y---%m-%d %X",time.localtime()))#2020---06-04 16:25:57 #------将字符串时间转成结构化时间strptime # print(time.strptime("2016:12:24:17:50:36","%Y:%m:%d:%X")) print(time.asctime()) print(time.ctime()) #Thu Jun 4 16:25:57 2020 #Thu Jun 4 16:25:57 2020# import datetime print(datetime.datetime.now())#2020-06-04 16:25:57.459925