37,743
社区成员
发帖
与我相关
我的任务
分享
class Stack(object):
def __init__(self):
self.stack=[]
def push(self,object):
self.stack.append(object)
def pop(self):
self.stack.pop()
def length(self):
return len(self.stack)
s=Stack()
s.push("Dave")
s.push(42)
s.push([3,4,5])
print s.length()
print s.pop()
y=s.pop()
print y
del sclass Stack(object):
def __init__(self):
self.stack=[]
def push(self,object):
return self.stack.append(object)
def pop(self):
return self.stack.pop()
def length(self):
return len(self.stack