1 Import Time2 #Timestamp : Total number of seconds 1970.1.1.08:00:00 up to now3 #-----------------------------Time module built-in functions-----------------------------4 #Time.altzone #返回格林威治西部的夏令时地区的偏移秒数5 Print("offset seconds for daylight saving time zone: Time.altzone%d"%Time.altzone)6 7 Print("\ n-----------------split line-----------------\ n")8 9 #Time.localtime () returns a time tuple of local time, if the timestamp is passed, returns the time tuple of the corresponding timestampTen Print("time.localtime ():", Time.localtime ()) One Print("Time.lcoaltime (1.0):", Time.localtime (1.0)) A - Print("\ n-----------------split line-----------------\ n") - the #Time.asctime Accept Time tuple ([tupletime]) return "Tue Dec 11 18:07:14 2008" (December 11, 2008 Tuesday 18:07 14 seconds) - Print("Time.asctime (Time.localtime ()):%s"%Time.asctime (Time.localtime ())) - - Print("\ n-----------------split line-----------------\ n") + - #Time.clock () returns the current CPU time using the number of seconds calculated by the yo floating point. + Print("Time.clock ()%s"%Time.clock ()) A at Print("\ n-----------------split line-----------------\ n") - - #time.ctime ([secs]) functions equivalent to Asctime (localtime (secs)), parameter is equivalent to Asctime () - Print("time.ctime ():", Time.ctime ()) - - Print("\ n-----------------split line-----------------\ n") in - #time.gmtime ([secs]) accepts a timestamp (the number of floating-point seconds elapsed in the 1970 ERA), returning the time tuple under Greenwich Astronomical TIME to Print("time.gmtime ([secs])", Time.gmtime ()) + - Print("\ n-----------------split line-----------------\ n") the * #Time.mktime (t) accept time-tuple return timestamp $ Print("Time.mktime (Time.localtime ()):", Time.mktime (Time.localtime ()))Panax Notoginseng - Print("\ n-----------------split line-----------------\ n") the + #time.sleep (secs) Deferred call thread run, secs refers to number of seconds ATime.sleep (10) the + Print("\ n-----------------split line-----------------\ n") - $ #Time.strftime (Fmt[,tupletime]) accepts a time tuple, returns a string, formatted as determined by the FMT $ Print(Time.strftime ("%y-%m-%d%h:%m:%s", Time.localtime ())) - - Print("\ n-----------------split line-----------------\ n") the - #Time.time () returns the current timestamp (the number of floating-point seconds elapsed after the 1970 era)Wuyi Print("time.time ():", Time.time ())
Python Learning Notes--time module built-in functions and examples