python父類可以訪問子類屬性,即便沒在父類中定義的屬性

如題。python In [25]: class A(object): ...: def f(self): ...: print(self.p) ...: In [26]: class B(A): ...: p = 'This is in B' ...: In [27]: B().f() Th
相關文章
相關標籤/搜索