Python--类-例子

class Base:
def __init__(self):
self.data = []
def add(self, x):
self.data.append(x)
def addtwice(self,x):
self.add(x)
self.add(x)

class Child(Base):
def plus(self, a, b):
return a+b
oChild = Child()
oChild.add("Str1")
print(oChild.data)
print(oChild.plus(2, 3))

  

posted @ 2015-12-11 21:07  [无名]  阅读(181)  评论(0编辑  收藏  举报