|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
class C:
counter = 0
def __setattr__(self,name,value):
C.counter += 1
super().__setattr__(name,value)
def __delattr__(self,nanme):
C.counter -= 1
super().__delattr__(name)
a =C()
a.x=1
del a.x
Traceback (most recent call last):
File "<pyshell#52>", line 1, in <module>
del a.x
File "E:/45-0.py", line 10, in __delattr__
super().__delattr__(name)
NameError: name 'name' is not defined
为什么'name'未定义呢,这里不应该已经定义了吗
def __delattr__(self,name) 这一行,name你多打了个n
|
|