时间:
tickets
时间元组
格式化的时间
日历
import tickets = time.time() print tickets print print print
import print |
CPU时钟:clock
睡眠:sleep
创建时间:mktime
#clock & sleep import def procedure(): time.sleep(0.5)
t0 = time.clock() procedure() print #mktime t = (2009, 2, 17, 17, 3, 38, 1, 48, 0) secs = time.mktime(t) print print |
datetime:类似C#的DateTime
import dt = datetime.datetime(2015,8,11,10,31,55) print dt print dt.hour print dt.second
delta = datetime.timedelta(hours=5) print dt + delta print dt - delta
from format = "output-%Y-%m-%d-%H%M%S.txt" str = "output-1997-12-23-030000.txt" t = datetime.strptime(str, format)
from print print |