【Python】decorator-CSDN博客网友收藏

【Python】decorator-CSDN博客

编写decorator:首先编写decorator函数,以@log为例:def log(f): def fn(x): print 'call ' + f.__name__ + '()...' return f(x) return fn在这里,log函数中定义了一个fn函数,fn中打印了log并返回f,log函数返回fn。注意,这......
阅读全文