1.datetime
当前时间:
datetime.datetime.now()
2.时间段
Attribute Value
days Between -999999999 and 999999999 inclusive
seconds Between 0 and 86399 inclusive
microseconds Between 0 and 999999 inclusive
在给timedelta赋值时可以用hours/weeks等,但是这些不在其属性内,属性只有以上三个
datetime.timedelta(hours=1000)
==>datetime.timedelta(41, 57600)
3.time
time.time() 实际时间
time.clock() cpu时间
time.sleep() 以秒为单位睡眠
4.格式
内置标准格式:
a=datetime.datetime.now()
a ==>datetime.datetime(2016, 1, 22, 15, 42, 14, 134797)
a.isoformat() ==>’2016-01-22T15:42:14.134797’
个性化格式:
a.strftime(‘%m%d%Y’)
转换成datetime对象
datetime.datetime.strptime('2008-08-08'`这里写代码片`,'%Y-%m-%d')
5.
time.time()实际时间
time.clock()cpu运行时间