'function' object has no attribute '_name_'错误
来源:互联网 发布:vr头显 知乎 pano 编辑:程序博客网 时间:2024/06/05 09:24
试验装饰器decorator的代码时:
def log(func): def wrapper(*args,**kw): print('call %s():'%func._name_) return func(*args,**kw) return wrapper@logdef now(): print('2017-7-21')now()
出现报错:AttributeError: ‘function’ object has no attribute ‘name’
后发现错误func.name应该为func._name_
于是代码改为:
def log(func): def wrapper(*args,**kw): print('call %s():'%func.__name__) return func(*args,**kw) return wrapper@logdef now(): print('2017-7-21')now()
build,运行正确!
阅读全文
0 0
- 'function' object has no attribute '_name_'错误
- AttributeError: 'function' object has no attribute '_name_'
- python 提示错误AttributeError: type object 'str' has no attribute '_name_'
- python机器学习实战3.2提示错误AttributeError: type object 'str' has no attribute '_name_'
- Python:AttributeError: 'function' object has no attribute '_doc_'
- yum错误'module' object has no attribute 'iterparse'解决方法
- python 3.x 错误 ‘generator’ object has no attribute ‘next’
- openstack:''Client'' object has no attribute ''service_catalog''错误
- [python错误]builtins.AttributeError: 'module' object has no attribute 'request'
- python 3.2 错误 ‘generator’ object has no attribute ‘next’
- python 编译错误TypeError: 'builtin_function_or_method' object has no attribute '__getitem__'
- python 3.x 错误 ‘generator’ object has no attribute ‘next’
- AttributeError: 'NoneType' object has no attribute 'execute' 错误的解决
- python 错误解析 AttributeError: 'module' object has no attribute 'dumps'
- 出现错误如下:AttributeError: 'module' object has no attribute 'SSL_ST_INIT'
- python 3.x 错误 ‘generator’ object has no attribute ‘next’
- Python 错误:AttributeError: 'module' object has no attribute
- Django错误:AttributeError: 'WSGIRequest' object has no attribute 'Post'
- 干货 | 算法工程师入门第二期——穆黎森讲增强学习(一) 本文作者:大牛讲堂编辑:刘芳平2017-07-19 11:38 导语:地平线大牛讲堂算法工程师入门第二期来啦!本期地平线资深算法工程师、增
- 概率相关高频面试题 如何求最大公约数
- 印刻学院_怎么做产品
- HashTable和HashMap
- Android WifiManager.WifiLock 简介
- 'function' object has no attribute '_name_'错误
- // PNG 转 PDF
- 招商银行、To B智能投顾讲述:金融机构的人工智能实践 | CCF-GAIR 2017
- 实战 SSH 端口转发
- SQL查询某个时间段购买过商品的所有用户
- find the most comfortable road
- WebService到底是什么
- session有效时间问题
- 视图简介