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()
相關文章
相關標籤/搜索