-
多重繼承 多態(tài)性查看全部
-
類的實(shí)例化過程-----__new__
查看全部 -
函數(shù):直接用函數(shù)名調(diào)用的
方法:類的一部分
查看全部 -
類的方法也是類的屬性查看全部
-
__init__是構(gòu)造函數(shù)
classmethod類似于C++的靜態(tài)成員函數(shù),直接使用類名進(jìn)行訪問
property的調(diào)用使用 對(duì)象名.屬性名,與一般函數(shù)不同后面不用加括號(hào)
查看全部 -
好查看全部
-
設(shè)置對(duì)象屬性
def __setattr__(self, name, value):
????self.__dict__[name] = value
查詢對(duì)象屬性
__getattr__(self,name):默認(rèn)情況沒有被查詢這個(gè)情況下會(huì)調(diào)用
__getattribute__(self, name):每次訪問屬性就會(huì)被調(diào)用到,注意容易 引起無限遞歸
刪除對(duì)象屬性
__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
查看全部
舉報(bào)