time.mktime(t)
t -- 這是struct_time或全滿9個元素的元組。
#!/usr/bin/python3 import time t = (2016, 2, 15, 10, 13, 38, 1, 48, 0) d=time.mktime(t) print ("time.mktime(t) : %f" % d) print ("asctime(localtime(secs)): %s" % time.asctime(time.localtime(d)))
time.mktime(t) : 1455511418.000000 asctime(localtime(secs)): Mon Feb 15 10:13:38 2016