def is_root(root):
def deco(func):
def wrapper(*args,**kwargs):
# if root == 1:
res = add_student(*args,**kwargs)
# else:
# res = -1
# print('未获取root信息,error')
return res
return wrapper
return deco
@is_root(root = 1) #deco
def add_student(x):
print('添加学生信息',x)
return 1
print(add_student(1))
要在add的基础上增加判断root的功能