【Python】decorator

編寫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。注意,這裏的f.__na
相關文章
相關標籤/搜索