1 >>> time.localtime ()2 time.struct_time (tm_year=2016, tm_mon=8, tm_mday=26, tm_ Hour=16, tm_min=21, tm_sec=38, tm_wday=4, tm_yday=239, tm_isdst=0)3 >>> time.gmtime () 4 time.struct_time (tm_year=2016, tm_mon=8, tm_mday=26, Tm_hour=8, tm_min=21, tm_sec=44, tm_wday=4, tm_ yday=239, tm_isdst=0)
time stamp conversion to a tuple1 >>> a =time.localtime ()2 >>> a3 time.struct_time (tm _year=2016, Tm_mon=8, tm_mday=26, tm_hour=16, tm_min=23, tm_sec=31, tm_wday=4, tm_yday=239, tm_isdst=0)4< /c6> >>> Time.mktime (a)5 1472199811.0
tuples converted to timestamps1>>a2Time.struct_time (tm_year=2016, tm_mon=8, tm_mday=26, tm_hour=16, tm_min=23, tm_sec=31, tm_wday=4, tm_yday=239, tm_ isdst=0)3>>> Time.strptime ('2016-12-12 12:12:12',"%y-%m-%d%h:%m:%s")4Time.struct_time (tm_year=2016, tm_mon=12, tm_mday=12, tm_hour=12, tm_min=12, tm_sec=12, tm_wday=0, tm_yday=347, tm_ Isdst=-1)5>>> Time.strftime ("%y-%m-%d%h:%m:%s", a)6 '2016-08-26 16:23:31'tuples and Formatting1 >>> a= time.localtime ()2 >>> a3 time.struct_time (tm _year=2016, Tm_mon=8, tm_mday=26, tm_hour=16, tm_min=26, tm_sec=42, tm_wday=4, tm_yday=239, tm_isdst=0)4< /c6> >>> Time.asctime (a)5'Fri-16:26:42'
tuples converted to strings1 >>> a = time.mktime (time.localtime ())2 >>> a3 1472200092.04 >>> time.ctime (a)5'Fri 16:28:12 '
Timestamp converted to string1 >>> datetime.datetime.now ()2 datetime.datetime (8, 6, 74390) 3 >>> datetime.datetime.now () + Datetime.timedelta ( -4)4 datetime.datetime ( 8, 625394,5 >>> datetime.datetime.now () + Datetime.timedelta (hours=9) )6 datetime.datetime (2016, 8, 27, 1, 29, 16, 201594)
datetime