#!usr/bin/env python
#-*- coding:utf-8 _*-
__author__ = "admin"
user,pwd = "admin","admin123"
def author(func):
def wrapper(*args,**kwargs):
userName = input("input your username:").strip()
password = input("input your password:").strip()
if userName == user and password == pwd:
print("\033[32;1mUser has passed authentication\033[0m")
func(*args,**kwargs)
else:
print("\033[31;1mInvalid username or passeord\033[0m")
return wrapper
def index():
print("welcome to my index page")
@author
def home():
print("welcome to my home page")
@author
def bbs():
print("welcome to my bbs page")
index()
home()
bbs()
python 装饰器
最新推荐文章于 2024-04-12 10:34:01 发布