import time user,passwd = "chenpeng","abc123" def auth(MyType): print(MyType) def login(func): def w(*args, **kwargs): username = input("UserName:") password = input("Password:") if user == username and passwd == password: print("\33[32;1mUser hhhh\033[0m") return func(*args, **kwargs) else: exit("登陆不成功") return w return login def index(): print("index") @auth(MyType = "one") def home(): print("home") return "aaa" @auth(MyType = "two") def bbs(): print("bbs") index() print(home()) bbs()
装饰器——python
最新推荐文章于 2024-07-22 21:43:03 发布