0%
简介
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
class Cat(): __cat_type = 'cat'
def __init__(self,name,sex): self.name = name self.__sex = sex def run(self): result = self.__run() print(result) def __run(self): return f'小猫{self.__cat_type,self.name,self.__sex}开心的奔跑' def dump(self): result = self.__dump() print(result) def __dump(self): return f'小猫{self.__cat_type,self.name,self.__sex}开心的跳着'
class Test(): pass
cat = Cat(name='米粒儿',sex='boy') cat.run() cat.dump()
print(dir(cat)) print(cat._Cat__dump()) print(cat._Cat__cat_type)
|