老师,没明白为什么要在外面再套一层,不能像下面传a,b,c一样直接传参数吗?
#coding=utf-8
def mylog(type):
def decorator(func):
def infunc(*args,**kwargs):
if type == '文件':
print('文件中:日志记录')
else:
print("控制台:日志记录")
return func(*args,**kwargs)
return infunc
return decorator
@mylog('文件')
def fun2(a,b,c):
print('fun2 run!',a,b,c)
if __name__ == '__main__':
fun2(100,200,300)
就是fun2中传的参数和这样再套一层传的参数作用哪里不一样?