name, passworld = 'luo', 'luo123'
def deco(way_):
def log_on_way(func):#func参数代表的是index_函数体空间的路标---index_
def func1(testing):#func1包含index_,于是,index_的参数,相当于func1。注意!!参数是通过index_的形参传递而来。
if way_ == 'file':
if input('name:') == name and input('passworld:') == passworld:
func(testing)#相当于index_和它的参数的合体,事实上,函数名和参数并非分开传递,而是函数名代表了这个函数体空间,而函数体空间中包含参数
else:
print('False')
elif way_ == 'checking':
print('make checking way log on')
return func1
return log_on_way
@deco(way_ = 'file')#index_ = func1(index_)
def index_(testing):#index_参数是直接传递至倒数第一层,而index_是传递给倒数第二层,第三层是@deco的参数。
print('welcome to index_', testing)
@deco(way_ = 'checking')
def home_():
print('welcome to home')
index_('luo')
# home_()#home_会报错,是因为没有传递参数,注意!func1的形参使用的不是通用形参。