TypeError: 'NoneType' object is not callable
TypeError: 'NoneType' object is not callable
def login(func):
def _login(*args, **kwargs):
if account["is_authenticated"] is False:
user = input('user:')
password = input('password:')
if user == account["username"] and password == account["password"]:
print("welcome %s" % user)
account["is_authenticated"] = True
else:
print("wrong username or password!")
if account["is_authenticated"]:
func(*args, **kwargs)
return _login
@login
def sichuan():
print("sichuan region.")
sichuan()
错误信息是:“NoneType” 对象不可调用,报错提示在最后一行,原因在于装饰器外部函数应该返回内部函数的地址,上面代码并没有返回,导致此错误发生。