Day 39 learning python time module built-in module

The learning module carrying # Time 
#time module: 1, the time stamp; meaning is convenient for doing operation; 2, the structure of the time; 3, string time
Import Time
# # timestamp
represents # print (time.time ()) # at 0:00 on January 1, 1970 00:00 Shi now with the number of seconds in 1970 was the birth of time liunx
## structured time ---- Local time
# print (time.localtime ()) # results obtained : a time.struct_time (tm_year = 2019, 10 = tm_mon, tm_mday =. 3, tm_hour =. 17, tm_min =. 7, 44 is tm_sec =, = tm_wday. 3, tm_yday = 276, the tm_isdst = 0)
#
# # the following methods can play when the corresponding month of year, day, hour
# t = time.localtime () # parameters have time.localtime (the time.time ())
# Print (t.tm_year)
# Print (t.tm_mon)
#
# # structure of time - --utc
# Print (time.gmtime ()) # structured save time difference method of the above 8 hours

# string time: Attractive convenience, I see a format is usually


## to convert into a structured time stamp
# Print (time.mktime (time.localtime ()))
#
# # structured time to convert string time
Print # (The time.strftime ( "% D%% Y-M-% H:% M:% S", time.localtime ()))
# Print (The time.strftime ( "% D%% Y-M-% X ", time.localtime ())) #% X and% H:% M:% S represents the same
#
# # string structured time into time
# print (time.strptime (" 2019: 10: 04 :. 17: 29: 20 is "," the Y%:% m:% D:% H:% m:% S "))
# # results: time.struct_time (tm_year = 2019, tm_mon = 10, tm_mday = 4, tm_hour . 17 =, tm_min = 29, = 20 is tm_sec, tm_wday =. 4, tm_yday = 277, the tm_isdst = -1)
#
# # directly secured display
# print (time.asctime ()) # Thu Oct 3 17:35:02 2019; structured time displayed
# print (time.ctime ()) # Thu Oct 3 17:35:02 2019; a time stamp to a fixed form of embodiment shown
#
# # suspend operation program
# time.sleep (5)

datetime Import
Print (datetime.datetime.now ()) # 2019-10-03. 17: 39: 47.490583 better display time

time module

 time module performance in time there are three main formats:

  a, timestamp timestamp, the timestamp indicates the beginning from January 1, 1970 00:00:00 1st shift amount calculated in seconds

  b, struct_time time tuples, a total of nine groups of elements.

  c, format time format time, formatted structure makes time more readable. Comprising a fixed format and custom format.

1, FIG time format conversion:






Guess you like

Origin www.cnblogs.com/jianchixuexu/p/11620276.html