Others do see a time stamp, the conversion formatting time, we also engage in a
1, a timestamp format conversion time
Time Import DEF str_to_stamp: (STR = None, the format = '% Y-M-% D%% H:% M:% S') , if not pass # formatted formatted time stamp of the time of revolution , returns the current timestamp IF STR: return int (time.mktime (the time.strptime (STR, the format))) the else: return int (the time.time ()) Print (str_to_stamp ()) Print (str_to_stamp ( '2019 22:23:24 12, -13, ')) Print (str_to_stamp (' 2019-12-13 ',' M-%%% Y-D ')) 1575516985 1,576,247,004 1576166400
2, the time stamp format conversion
Time Import DEF stamp_to_str (Stamp = None, the format = '% Y-M-% D%% H:% M:% S'): '' 'is to convert the time stamp into actual formatted, if not pass stamp, it returns the current time '' ' IF stamp: return the time.strftime (the format, time.localtime (stamp)) the else: return the time.strftime (the format, time.localtime ()) Print (stamp_to_str (1575516985, 'M-%%% Y-D')) Print (stamp_to_str (= the format 'M-%%% Y-D')) Print (stamp_to_str ()) 2019-12-05 2019-12-05 2019-12- 05 11:52:37