编写装饰器, 在每次执行被装饰函数之前让用户输入用户名, 密码, 给用户三次机会, # 登录成功之后, 才能访问该函数


# def wrapper(fn):
# def inner(*args, **kwargs):
# count = 0
# while count < 3:
# username = input("请输入你的用户名:")
# password = input("请输入你的密码:")
#
# if username == "alex" and password == "shuai":
# # 登录成功之后
# ret = fn(*args, **kwargs) # 可能会执行你的函数
# return ret
# else:
# print("登录失败!")
# count += 1
# return inner
#
#
# @wrapper
# def func():
# print("今天主要玩儿wusir")
#
#
# func()

猜你喜欢

转载自www.cnblogs.com/bpbl/p/10209221.html
今日推荐