#装饰器练习
useName = input('输入用户名:')
passWord = input('输入密码:')
def login(func):
def inner(*arg):
if(useName=='zhang' and passWord=='123'):
print('用户校验通过')
func(*arg)
else:
print('账户或密码错误')
return
return inner
@login
def function1(useName,age):
print("%s:你好,这是方法一%s" % (useName,passWord))
@login
def function2(useName):
print("%s:你好,这是方法二" % useName)
def function3(useName):
print("%s:你好,这是方法三" % useName)
function1('li','123')
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240813180353098-2140851696.jpg)