class base():
def __init__(self):
self.b = 5
def step(self):
c = self.a
print(c)
def creat(self):
self.pr()
class A(base):
def __init__(self):
self.i = 1
print(self.i)
base.__init__(self)
def pr(self):
self.a = 999
b = A()
b.creat()
b.step()
#输出
#1
#999
2两个例子一样
class base():
def step(self):
c = self.a
print(c)
def creat(self):
self.pr()
class A(base):
def pr(self):
self.a = 999
b = A()
b.creat()
b.step()
#输出 999