Discuss / Python / 打卡

打卡

Topic source

import time, functools

def outer(origin):

    @functools.wraps(origin)

    def inner(*args, **kwargs):

        print('%s executed in %s ms' % (origin.__name__, 10.24))

        res = origin(*args, **kwargs)

        return res

    return inner

@outer

def fast(x, y):

    time.sleep(0.0012)

    return x + y;

@outer

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('测试失败!')


  • 1

Reply