怎么样为装饰器加参数
import time current_user = {'user':None} def auth(engine = "file") def deco(func): def wrapper(*args,**kwargs): if current_user['user']: #已经登录过 res = func(*args,**kwargs) return res user = input("username>>>:").strip() pwd = input("password>>>:").strip() if engine == 'file': #基于文件的认证 if user == “egon‘ and pwd == "123": print('login successful') current_user['user'] = user res = func(*args,**kwargs) return res else: print('user or password error') elif engine == 'mysql': print('基于MySQL的认证') elif engine == 'mysql': print('基于MySQL的认证') elif engine == 'ldap': print('基于ldap的认证') else: print('无法识别认证来源') return wrapper return deco @auth(engine = ”mysql“) def index(): print('welcome to index page') time.sleep(1) index()