1 import time 2 print (time.time()) #Seconds from 1970 to the present, timestamp 3 a = time.localtime() 4 print (time.localtime(1232549153)) #Current time zone structured time struct_time 5 print (a.tm_year) #structured time can be taken out 6 print (time.gmtime()) #time standard time UTC 7 print (time.mktime(time.localtime())) #structured time is converted into timestamp 8 time.sleep(5) #Sleep for 5s and continue to execute 9 10 print(time.strftime( ' %Y-%m-%d-%H-%M-%S ' ,time.localtime())) #Convert structured time to daily string time 11 print (time.strftime( ' %Y-%m-%d-%X ' ,time.localtime())) # %X == %H-%M-%S 12 print (time.strptime( ' 2018:04:23:13:57 :35 ' , ' %Y:%m:%d:%X ' )) #Convert string time into structured time 13 14 print (time.asctime( time.localtime ())) #When outputting string type , you can add parameter 15 print (time.ctime()) #It seems that you can't add parameters 16 17 import datetime 18 print (datetime.datetime.now()) #The habit of watching 2018-04-23 14:36:08.418508