|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- class C:
- def __getattribute__(self, name):
- print("getattribute")
- return super().__getattribute__(name)
- def __getattr__(self, name):
- print("getattr")
- def __setattr__(self, name, value):
- print("setattr")
- super().__setattr__(name, value)
- def __delattr__(self, name):
- print("delattr")
复制代码
输入代码及结果如下:
- c=C()
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
- getattribute
复制代码
后面的c.x c.x=1等命令都能得到正确输出,但每个输出后面都会跟一大串的getattribute,这和书上p133的例题输出结果不同,求各位大佬解释
运行环境为spyder(python3.6) |
|