import time def decorator(func): def wrapper(): print time.time() func() return wrapper def f1(): print('xxxxxx') f= decorator(f1) f()
import time def decorator(func): def wrapper(): print time.time() func() return wrapper @decorator def f1(): print('xxxxxx') f1()
import time def decorator(func): def wrapper(name): print time.time() func(name) return wrapper @decorator def f1(name): print('xxxxxx'+name) f1('eeeee')
import time def decorator(func): def wrapper(*args): print time.time() func(*args) return wrapper @decorator def f2(n,m): print('xxxxxx'+n+m) f2(1,3)