python 装饰器(语法糖)
def login(func):
def testlogin():
for i in range(3):
_username="abc"
_passwrod="123456"
user_status = False
iuput = input("请输入账号:")
input1 = input("请输入密码:")
if iuput == _username and input1 == _passwrod:
user_status = True
func()
break
else:
print("输入的账号或密码不正确请重新输入")
print("------------------------")
continue
if user_status == False:
print("超出输入限制,自动退出")
return testlogin
@login
def moving():
print("vip窗口---------------")
def putong():
print("游客窗口----------------")
@login
def test():
print("普通用户------------------")
def test123():
zidian = {1:"vip窗口",2:"游客窗口",3:"普通用户"}
print(zidian)
for i in range(10):
input2 = int(input("请输入您选择的ID:::"))
if input2 in zidian.keys():
print(zidian[input2])
if zidian[input2] == "vip窗口":
moving()
break
if zidian[input2] == "普通用户":
test()
break
if zidian[input2] == "游客窗口":
putong()
break
print("输入有误,请重新输入")
continue
test123()