user, passwd = 'jd', 'jd123456' #JD账号
user1, passwd1= 'wx', 'wx123456' #wx账号
flag = False
def args1(auth ='jd'):
if auth =='jd':
def demo(func):
def inner():
global flag
if flag == False:
user_jd = input('please your name: ')
passwd_jd = input('please your passwd: ')
if user_jd == user and passwd_jd == passwd:
flag = True
print ('登录成功')
func()
else:
print ('登录失败')
elif flag == True:
func()
return inner
return demo
elif auth == 'wx':
def demo(func):
def inner():
global flag
if flag == False:
user_wx = input('please your name: ')
passwd_wx = input('please your passwd: ')
if user_wx == user1 and passwd_wx == passwd1:
flag = True
print('登录成功')
func()
else:
print('登录失败')
elif flag == True:
func()
return inner
return demo
@args1()
def home():
print('home')
@args1()
def book():
print('book')
home()
book()