class Simple:
def __init__(self, s):
print("inside the simple constructor")
self.s = s def show(self):
print(self.s)
def showMsg(self, msg):
print(msg + ':', self.show())Simples
if __name__ == "__main__":
x = Simple("constructor argument")
x.s = "test15" # this changes the value
x.show()
x.showMsg("A message")Python在类中有“私有”变量吗?
慕慕森
白衣非少年
哔哔one
相关分类