Laozizuiku 2019-12-16
def log(text=None): if isinstance(text, str): def decorator(func): @functools.wraps(func) def wrapper(*args, **kw): print(‘%s %s():‘ % (text, func.__name__)) return func(*args, **kw) return wrapper return decorator else: @functools.wraps(text) def wrapper(*args, **kw): print(‘call %s():‘ % text.__name__) return text(*args, **kw) return wrapper