Python中的装饰器之@wraps(四)

def wrapper(func):

    @wraps(func)  # 修改名称空间: inner ---》 func
    def inner(*args, **kwargs):
        '''
        此处是装饰器的注释
        :param func:
        :return:
        '''
        res = func(*args, **kwargs)
        return res
    return inner  # ---》 func


@wrapper
def index():
    '''
    此处是index函数的注释
    :return:
    '''
    pass

以上

猜你喜欢

转载自www.cnblogs.com/Ghostant/p/11853179.html