Python/ref func delattr
来自菜鸟教程
<languages />
Python delattr()函数
例
从“人员”对象中删除“年龄”属性:
class Person:
name = "John"
age = 36
country = "Norway"
delattr(Person, 'age')
定义和用法
The
delattr()
函数将从指定对象中删除指定属性。
句法
delattr(object, attribute)
参数值
| 参数 | 描述 |
|---|---|
| object | 需要。一个东西。 |
| attribute | 需要。您要删除的属性的名称 |
相关页面
The getattr()
函数,获取属性值
The hasattr()
函数,检查属性是否存在
The setattr()
函数,用于设置属性的值