AttributeError: 'function' object has no attribute '_name_'
2016-10-20 21:14
1091 查看
def log(text):
def decorator(func):
def wrapper(*args,**kw):
print '%s %s():'%(text,func._name_)
return func(*args,**kw)
return wrapper
return decorator
@log('execute')
def now():
print '2016-10-20'
print now()
AttributeError: 'function' object has no attribute '_name_'
def log(text):
def decorator(func):
def wrapper(*args,**kw):
print '%s %s():'%(text,func.__name__)
return func(*args,**kw)
return wrapper
return decorator
@log('execute')
def now():
print '2016-10-20'
print now()
错误就在红色标记处,结果是因为”__doc__“写成了”_doc_“:
def decorator(func):
def wrapper(*args,**kw):
print '%s %s():'%(text,func._name_)
return func(*args,**kw)
return wrapper
return decorator
@log('execute')
def now():
print '2016-10-20'
print now()
AttributeError: 'function' object has no attribute '_name_'
def log(text):
def decorator(func):
def wrapper(*args,**kw):
print '%s %s():'%(text,func.__name__)
return func(*args,**kw)
return wrapper
return decorator
@log('execute')
def now():
print '2016-10-20'
print now()
错误就在红色标记处,结果是因为”__doc__“写成了”_doc_“:
相关文章推荐
- 执行Python程序时,报AttributeError: 'function' object has no attribute 'name'
- 'function' object has no attribute '_name_'错误
- AttributeError: 'classmethod' object has no attribute '__module__'
- AttributeError: ‘NoneType’ object has no attribute ‘clone’
- AttributeError: type object 'IOLoop' has no attribute 'initialized'
- PyQt: “AttributeError: 'Form' object has no attribute 'exec_'” when opening second window
- AttributeError: 'module' object has no attribute 的解决方法
- python :TypeError: 'builtin_function_or_method' object has no attribute '__getitem__'
- AttributeError: 'module' object has no attribute 'text_format'
- AttributeError: 'module' object has no attribute '_base' 可行解决办法
- AttributeError: 'module' object has no attribute(转)
- AttributeError: 'FeedExporter' object has no attribute 'slot'
- AttributeError: 'module' object has no attribute '_handlerList' 错误解决方法
- python 使用 pip 安装 三方库的时候报错 “AttributeError: '_socketobject' object has no attribute...”
- AttributeError: 'NoneType' object has no attribute 'clone'
- AttributeError: '_NamespacePath' object has no attribute 'sort'
- Keras深度学习框架学习笔记(3) - AttributeError:’module’ object has no attribute ‘ifelse’错误信息的解决方法
- AttributeError: 'google.protobuf.py ***' object has no attribute '_value'
- python AttributeError: 'module' object has no attribute 'dumps'解决办法
- AttributeError: 'NoneType' object has no attribute