Discuss / Python / 全部实现

全部实现

Topic source

JIBANCANYANG

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

import functools

def log(text = ''): def decorator(func): @functools.wraps(func) def wrapper(args, **kw): temp = func(args, **kw) print('end call:%s' % (text)) return temp print('begin call:%s' % (text)) return wrapper return decorator

@log() def doit(x = 2): print(x * x)

doit()


  • 1

Reply