Python 内建函数 - delattr(object, name)
2017-03-14 10:50
225 查看
Manual
直译
实例
拓展阅读
hasattr()
getattr()
直译
实例
拓展阅读
Manual
This is a relative of setattr(). The arguments are an object and a string. The string must be the name of one of the object’s attributes. The function deletes the named attribute, provided the object allows it. For example, delattr(x, ‘foobar’) is equivalent to del x.foobar.直译
该函数与setattr()关联,参数是一个对像和一个字符串,字符串必须是对象中某个属性名称,该函数删除以此命名的属性。例如:delattr(x, ‘foobar’)等同于del x.foobar。实例
>>> class CSDN: def foobar(self): print('Hello CSDNer!') >>> CSDN().foobar() Hello CSDNer! >>> delattr(CSDN, 'foobar') >>> CSDN().foobar() Traceback (most recent call last): File "<pyshell#153>", line 1, in <module> CSDN().foobar() AttributeError: 'CSDN' object has no attribute 'foobar'
拓展阅读
setattr()hasattr()
getattr()
相关文章推荐
- Python 内建函数 - hasattr(object, name)
- Python 内建函数 - getattr(object, name[, default])
- python内建函数hasattr(object, name)
- Python 内建函数 - setattr(object, name, value)
- python 中getattr(object,name,default),setattr(object,name,default),hasattr(),delattr()
- python文件中的__name__=='__main__'的使用及调用其他py文件中的函数方法
- python脚本中的函数开发时怎么调试(__name__=="__main__")
- Python标准库:内置函数getattr(object, name[, default])
- Python标准库:内置函数hasattr(object, name)
- Python 里的 super() 函数和 object.__new__ ()、.__del__() 方法
- Python 内建函数 - repr(object)
- Python标准库:内置函数hasattr(object, name)
- python︱函数、for、if、_name_、迭代器、防范报错、类定义、装饰器
- python中使用zip函数出现<zip object at 0x02A9E418>
- python调用对象属性出错:AttributeError: 'function' object has no attribute '_name_'
- Python标准库:内置函数hasattr(object, name)
- python 面向对象中一些常用内建函数【getattr(), setattr(). hasattr(). delattr()...】
- python 面向对象中一些常用内建函数【getattr(), setattr(). hasattr(). delattr()...】
- Python的__name__与__main__函数
- python函数 callable(object)