用装饰器实现模拟登陆

def test1(func):
    def test2(root,key):
        if root == "root" and key ==123:
            print("您的用户名和密码输入正确")
        else:
            print("您的用户名或密码输入错误")
    return test2


@test1
def test3(root,key):
    pass

test3("root",1234)
 
 

输出>>>您的用户名或密码输入错误

猜你喜欢

转载自blog.csdn.net/sun_daming/article/details/80426949
今日推荐