37,719
社区成员
发帖
与我相关
我的任务
分享
#父类
class School(object):
def __init__(self):
self.money = 1000
self.__money = 200000
def __money_info(self):
print(f'私房钱:[{self.__money}]')
def print_info(self):
self.__money_info()
def get_money(self):
return self.__money
# 子类
class Students(School):
pass
s = Students()
print(s.get_money()) # >>> 200000
s.print_info() # >>> 私房钱:[200000]
class Students(School):
def __init__(self):
pass
# 子类
class Students(School):
def __init__(self):
super().__init__()