-
多重繼承 多態性查看全部
-
類的實例化過程-----__new__
查看全部 -
函數:直接用函數名調用的
方法:類的一部分
查看全部 -
類的方法也是類的屬性查看全部
-
__init__是構造函數
classmethod類似于C++的靜態成員函數,直接使用類名進行訪問
property的調用使用 對象名.屬性名,與一般函數不同后面不用加括號
查看全部 -
好查看全部
-
設置對象屬性
def __setattr__(self, name, value):
????self.__dict__[name] = value
查詢對象屬性
__getattr__(self,name):默認情況沒有被查詢這個情況下會調用
__getattribute__(self, name):每次訪問屬性就會被調用到,注意容易 引起無限遞歸
刪除對象屬性
__delattr__(self, name):
查看全部 -
set attribute
def?__setattr_(self,?name,?value): ????self.__dict__[name]=value
查看全部 -
the process of creating an object
查看全部 -
polymorphism
查看全部 -
call parent class's method
查看全部 -
class inheritance syntax
查看全部 -
object.method()
func()
@classmethod: static method in a class
class.classmethod
@property: convert method into a field of the class
class?Programer(object): ????hobby='Play?video?games' ????def?__init__():........... ????@classmethld ????def?get_hobby(cls): ????????return?cls.hobby ????@property ????def?get_weight(self): ????????return?self.__weight ? ?main: ?programer_albert=Programer('Albert',?25,?80) ?print(Programer.hobby) ?print(programer_albert.get_weight)
查看全部 -
class?Name(inherited?class): ????self.property1 ????self.property2? ????#?Constructor ????def?__init__(self,?property1,?Property2): ????????self.property1=property1 ????????self.property2=property2 ???????? ????def?__del__(self,?[...):
查看全部 -
Properties: age, gender, height
Method (encapsulated): coding, repairing
Inheritance (multiple inheritances supported)
Polymorphism
查看全部
舉報