装饰器
staus = False
def login(func):
def inner(*args, **kwargs):
global staus
if staus == False:
user = input('user: ')
password = input('password: ')
if user == 'alex' and password == 'abc':
staus = True
else:
print('密码不对')
else:
print('用户已验证,通过')
if staus == True:
func(*args,**kargs)
return inner
def home():
print("---首页----")
def america():
print("----欧美专区----")
@login
def japan():
print("----日韩专区----")
@login
def henan():
print("----河南专区----")
# america = login(america) # 实际执行了函数,这不是我们想要的,想要的只是赋值,也就是返回函数的内存地址
# america('3P')
japan('PP')