Import time
Import re
Print Time.time ()
Print Time.localtime ()
A = ' tm_year=2016, tm_mon=5, tm_mday=28, tm_hour=6, tm_min=51, tm_sec=14, tm_wday=5, tm_yday=149, tm_isdst=0 '
b = Re.findall (' \d+ ', a)
Print B
c = []
For Tup in B:
t = Int (TUP)
C.append (t)
c = Tuple (c)
Print type (c)
Print C
# c = (2016, 5, 28, 6, 51, 14, 5, 149, 0)
Print Time.mktime (c)
Print Time.mktime (Time.localtime (1464389474.0)) # Tuple converted to timestamp, struct_time---> Timestamp
Print Time.localtime (1464389474.0)
Print Time.gmtime (1464389474.0) # Timestamp converted to tuple, timestamp--->struct_time
Print Time.strftime ('%y-%m-%d%h:%m:%s:%a:%b:%c:%j%p%u%w%w%x ', Time.localtime (1464389474.0))
Print Time.strftime ('%y-%m-%d%h:%m:%s ') # struct_time---> formatted string
Print Time.strptime (' 2016-05-28 06:51:14 ', '%y-%m-%d%h:%m:%s ') #格式化字符串--->struct time
#元组和字符串无法直接相互转化
#datetime
Python Time Module Timing processing