def func(data): def wrapper_func(data_func): def wrapper_inner(*args): if data: print(" start....") data_func(*args) return wrapper_inner return wrapper_func @func(data=False) def func_name(param): print(param) if __name__ == '__main__': func_name("test")
def log(*item, **data): def wrapper(func): def f(*args, **kwargs): print("log........{0}".format(args[0])) print(item[0]) print(data['key']) func(*args, **kwargs) return f return wrapper @log(1, key="dsideal_yy") def func(name): print(name) func("zhanghai1")