|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本帖最后由 永恒的蓝色梦想 于 2020-3-17 17:33 编辑
Python delattr() 函数
语法
描述
delattr() 函数用于删除对象的指定属性。delattr(x, 'y') 相当于 del x.y
参数
返回值
None
例子
- >>> class Test:
- testList=[]
- def testMethod(self):
- ...
- >>> Test.testList
- []
- >>> delattr(Test,'testList')
- >>> hasattr(Test,'testList')
- False
- >>>
- >>> Test.testMethod
- <function Test.testMethod at 0x0000022C02EB3040>
- >>> delattr(Test,'testMethod')
- >>> hasattr(Test,'testMethod')
- False
复制代码 |
|