def auth_func(func):
def wrapper(*args,**kwargs):
#参数检查,判断是否有用户登录,如果有,不用验证,直接执行函数的功能
if client_dic['username'] and client_dic['login']:
res = func(*args,**kwargs)
return res
#输入用户名和密码
username = input('用户名:').strip()
passwd = input('passwd:').strip()
#对比列表,检查用户名和密码是否正确
for user_dic in user_list:
if username == user_dic['name'] and passwd == user_dic['passwd']:
client_dic['username'] = user_dic['name']
client_dic['login'] = True
res = func(*args,**kwargs)
return res
else:
print('用户名或者密码错误!')
return wrapper
https://blog.csdn.net/qq_33531400/article/details/79324551def auth_func(func): def wrapper(*args,**kwargs): #参数检查,判断是否有用户登录,如果有,不用验证,直接执行函数的功能 if client_dic['username'] and client_di...