怎么样为装饰器加参数

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()

  

最新文章

  1. Java技能树
  2. FPGA低级建模---按键去抖动
  3. Anliven - 你的学习为何如此低效?!
  4. Spring3 整合MyBatis3 配置多数据源 动态选择SqlSessionFactory
  5. 161205、win10安装mysql5.7.16数据库
  6. HTML to DOM
  7. Xamarin 安装体验
  8. DecimalFormat
  9. oracle中的turnc,round,floor,ceil,coalesce函数
  10. oracle java连接配置
  11. Unsupervised pre-training
  12. JavaSE assert断言的学习
  13. day19 十九、ATM+购物车
  14. JAVA SpringBoot 项目打成jar包供第三方引用自动配置(Spring发现)解决方案
  15. MHA-手动Failover流程(传统复制&GTID复制)
  16. [蓝桥杯]ALGO-97.算法训练_排序
  17. 地图调起URI API(通过连接直接调用百度地图)
  18. nginx中server的匹配顺序
  19. hbase 学习(十二)非mapreduce生成Hfile,然后导入hbase当中
  20. mysql8.0 安装

热门文章

  1. python时间 time模块和datetime模块
  2. SP Flash Tool版本对应MTK处理器型号速查(SP Flash Tool Download)
  3. 关于distinct的compare参数的使用
  4. 【51nod1220】约数之和
  5. jquery keypress() 方法 语法
  6. 【POJ1011】Sticks
  7. HDU 3468:A Simple Problem with Integers(线段树+延迟标记)
  8. Alibaba DataX 源码编译
  9. Excel导入导出工具(简单、好用且轻量级的海量Excel文件导入导出解决方案.)
  10. web 多屏互动显示方案