#coding:utf-8 list=[{'name':'alex','passwd':'123123'}, {'name':'tom','passwd':'123123'}] current={'name':None,'passwd':False} def timmer(func): def wrapper(): if current['name'] and current['passwd'] : func() return 1 else: name=input("请输入用户名: ") passwd=input("请输入你的密码: ") for i in list: if i['name'] == name and i['passwd']== passwd : current['name']=name current['passwd']=True func() return 1 else : print("你输入的用户名或者密码错误") return wrapper @timmer def index(): print("欢迎来到京东首页") @timmer def home(): print("欢迎来到家目录") index() print(current) home()