#装饰器 实现不同部门对应不同登录密码
departments={"QQ":"Q","PP":"P","SS":"S"}
def department(dept):
def password_check(func):
def wrapper(*args):
temp_pw=input("请输入密码:")
my_dept=dept
if my_dept not in departments.keys():
print("该部门不存在!")
else:
if temp_pw==departments[dept]:
return func(*args)
else:
print('密码错误!')
return wrapper
return password_check
@department("QQ")
def test(my_txt,my_list):
list_new=map(lambda x:my_txt+str(x),my_list)
temp_list=list(list_new)
print("函数内打印-->",temp_list)
return temp_list
list2=[1,2,3,4,5,6]
txt2="百岁山"
temp_list=test(txt2,list2)
print("函数外打印-->",temp_list)