Use python time module

Import Time 

# current timestamp 
CURRENT_TIME = the time.time ()
 Print (CURRENT_TIME)
 # 1,567,498,447.616138 

# current time structured object - Local 
current_time_obj = time.localtime ()
 Print (current_time_obj)
 # a time.struct_time (tm_year = 2019, tm_mon . 9 =, = tm_mday. 3, tm_hour = 16, 16 = tm_min, tm_sec = 2, tm_wday =. 1, tm_yday = 246, the tm_isdst = 0) 

# structured object into a time stamp 
TIME_STAMP = time.mktime (time.localtime ())
 Print (TIME_STAMP)
 # 1,567,498,880.0 

# structured time the object into a string of time 
time_str the time.strftime = ( ' %% Y-X-M-% D% ', Time.localtime ())
 Print (time_str)
 # 2019-09-03 16:29:29 

# string into a structured time-time objects 
time_obj the time.strptime = ( ' 2016-09-09 00:00:00 ' , ' % Y-M-%%% X-D ' )
 Print (time_obj)
 # a time.struct_time (tm_year = 2016, = tm_mon. 9, tm_mday =. 9, tm_hour = 0, 0 = tm_min, tm_sec = 0, = tm_wday . 4, tm_yday = 253, the tm_isdst = -1) 

# delayed run-time, parameters of three seconds 
time.sleep (3)

 

Guess you like

Origin www.cnblogs.com/kehaimin/p/11453994.html