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
随时随地看视频慕课网APP
相关分类