import time
import datetime
print 'time.time()'
print time.time()
print
print 'strptime'
st = time.strptime("20140203", "%Y%m%d")
print st
print type(st)
print
# convert float to tuple (gmtime)
print 'gmtime'
print time.gmtime(time.time())
print
# convert tuple to float (mktime)
print 'mktime'
print time.mktime(st), '\n\n'
# strftime datetime->string
t = (2009, 2, 17, 17, 3, 38, 1, 48, 0)
t = time.mktime(t)
print time.strftime("%b %d %Y %H:%M:%S", time.gmtime(t))
print datetime.date(2014,5,31)
QuickDemo python_datetime
最新推荐文章于 2020-12-10 09:51:28 发布