Discuss / Python / 最后一题

最后一题

Topic source

Chena

#1 Created at ... [Delete] [Delete and Lock User]

import functools

from functools import reduce

def log(*text):

    def decorator(func):

        @functools.wraps(func)

        def wrapper(*args, **kwargs):

            if(len(text) != 0):

                print(reduce(lambda x,y: x+y, list(map(str,text))))

            re = func(*args, **kwargs)

            return re

        return wrapper

    return decorator

@log("text")

def dsf():

    print("def")

@log()

def abd():

    print("adc")

dsf()

abd()


  • 1

Reply