python_装饰器之页面登录验证

import timedef auth(func):    def wrapper(*args, **kwargs):        username = input('username:').strip()        password = input('password:').strip()        if username == 'admin' and password == '123':            func()        else:            exit()    return wrapper@authdef index():    print('index')@authdef home():    print('home')@authdef bbs():    print('bbs')# 方法调用index()home()bbs()
相关文章
相关标签/搜索