output 的順序不太理解
class Level1: variable_1 = 100 def __init__(self): self.var_1 = 101 def fun_1(self): print("3") return 102class Level2(Level1): variable_2 = 200 def __init__(self): super().__init__() self.var_2 = 201 def fun_2(self): super().fun_1() print("2") return 202class Level3(Level2): variable_3 = 300 def __init__(self): super().__init__() self.var_3 = 301 def fun_3(self): super().fun_2() print("1") return 302obj = Level3()print(obj.variable_1, obj.var_1, obj.fun_1())print(obj.variable_2, obj.var_2, obj.fun_2())print(obj.variable_3, obj.var_3, obj.fun_3())
output:
3
100 101 102
3
2
200 201 202
3
2
1
300 301 302
為什麼3 3 2 3 2 1會以這樣的順序出現