1. 程式人生 > >實現一個統計函數運行時間

實現一個統計函數運行時間

app n) for datetime code 當前 運行 一個 color

1.datetime顯示當前時間

import datetime


def Func(n):
    t = datetime.datetime.now()
    print t
    print "start **************"
    l=[]
    for i in range(1,10):
        l.append(i)
        time.sleep(1)
    e = datetime.datetime.now()
    print e
    print (e - t).seconds
Func(11)

實現一個統計函數運行時間