我就做个笔记
Pytho
def log(prefix): def log_decorator(f): def wrapper(*args, **kw): print ('[%s] %s()...' % (prefix, f.__name__)); return f(*args, **kw); return wrapper; return log_decorator; @log('DEBUG') def test(): pass; print test();
闭包与装饰器
Pytho
def log(prefix): def log_decorator(f): def wrapper(*args, **kw): print ('[%s] %s()...' % (prefix, f.__name__)); return f(*args, **kw); return wrapper; return log_decorator; @log('DEBUG') def test(): pass; print test();
闭包与装饰器
2016-07-28
举报