#!/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()
對于裝飾器理解不夠的話會寫出類似與上面的代碼,運行結尾就會出現(xiàn)'NoneType' object is not callable,把最后的:
hello()
改為
hello
就可以解決,具體解釋參考:
http://www.tuicool.com/articles/FBZvya