装饰器——python
2018-04-08 10:41
369 查看
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装饰器由浅入深
- python单例模式的装饰器
- Python中使用装饰器时需要注意的一些问题
- python 装饰器
- Python中装饰器的一个妙用
- Python装饰器之入门2
- Python使用装饰器模拟用户登陆验证功能示例
- Python装饰器与面向切面编程
- 对python装饰器的理解
- Python生成器、迭代器、装饰器
- 分层次理解python装饰器
- Python装饰器学习(九步入门)
- Python装饰器学习
- Python装饰器----应用示例(二)
- Python闭包和装饰器
- “模板方法”模式与Python装饰器的关系
- 简单 12 步理解 Python 装饰器
- Py修行路 python基础 (十)装饰器
- @修饰符--python中的装饰器
- Python学习笔记(2)装饰器