In Python, there are usually several ways to represent time:
Timestamp (timestamp): Typically, a timestamp represents an offset that is calculated in seconds, starting January 1, 1970 00:00:00. We run "type (Time.time ())" and return the float type.
Formatted time string (format string)
Structured time (Struct_time): Struct_time A total of 9 elements in total nine elements: (year, month, day, hour, minute, second, week of the year, Day of the year, summer Time)
The computer knows the time can only be ' timestamp ' format, and the programmer can deal with or say that humans can understand the time is: ' Formatted time string ', ' structured time ', so there is a conversion relationship:
650) this.width=650; "Src=" Https://s5.51cto.com/oss/201710/30/835206dd92ff14fb383c1598f9aaf810.png-wh_500x0-wm_3 -wmp_4-s_2690617683.png "title=" 1036857-20170215142700722-743334012.png "alt=" 835206dd92ff14fb383c1598f9aaf810.png-wh_ "/>
Time Code:
The implementation shows that the elapsed time is output in a formatted time format, such as a "hot in a few minutes" function on a forum or Weibo.
Def timeer ():
True_time=time.time () #发布的时间
Time.sleep (#模拟过去的时间)
Time_now=time.time () #现在的时间
Dif_time=time_now-true_time
Struct_time=time.gmtime (Dif_time)
Return ('%d%d '%d '%d '%d '% (struct_time.tm_year-1970,struct_time.tm_mon-1,struct_time.tm_mday-1,struct_ Time.tm_hour, Struct_time.tm_min,struct_time.tm_sec))
Python Time Module