python装饰器'NoneType' object is no
2016-10-03 本文已影响0人
Daniel_Lee
#!/usr/bin/env python3
# coding=utf-8
def simple_decorator(f):
print('enter function')
f()
print('exited function')
@simple_decorator
def hello():
print('hello world')
hello()
对于装饰器理解不够的话会写出类似与上面的代码,运行结尾就会出现'NoneType' object is not callable,把最后的:
hello()
改为
hello
就可以解决,具体解释参考:
http://www.tuicool.com/articles/FBZvya