Discuss / Python / 交作业

交作业

Topic source

import time

def metric(name):

    def wrap(*arge):

        print('now time:',time.ctime())

        print('%s executed in %s ms' % (name.__name__, 10.26))

        return name(*arge)

    return wrap

@metric

def fast(x, y):

    time.sleep(0.0012)

    return x + y

@metric

def slow(x, y, z):

    time.sleep(0.1234)

    return x * y * z

f = fast(11, 22)

s = slow(11, 22, 33)

if f != 33:

    print('测试失败!')

elif s != 7986:

    print('测试失败!')

为什么是10.26啊?


  • 1

Reply