关于__getattribute__
生活随笔
收集整理的這篇文章主要介紹了
关于__getattribute__
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
先看一個案例
class Tree(object):def __init__(self,name):self.name=nameself.cate='plant'def __getattribute__(self, item):if item=='大樹':print('log 大樹')return '我愛大樹'else:return object.__getattribute__(self,item)aa=Tree('rrrr') print(aa.name) print(aa.cate)運行結果:
rrrr plant?
轉載于:https://www.cnblogs.com/Kerryworld/p/10812798.html
總結
以上是生活随笔為你收集整理的关于__getattribute__的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 中信四川航空联名信用卡额度多少?额度分为
- 下一篇: ProtocolHandler继承体系