python AttributeError: 'Stack' object has no attribute 'stack'class Stack(object): def _init_(self): self.stack=[] def push(self,object): self.stack.append(object) def pop(self): return self.stack.pop() def length(sel
来源:学生作业帮助网 编辑:作业帮 时间:2024/05/21 03:03:53
python AttributeError: 'Stack' object has no attribute 'stack'
class Stack(object):
def _init_(self):
self.stack=[]
def push(self,object):
self.stack.append(object)
def pop(self):
return self.stack.pop()
def length(self):
return len(self,stack)
s=Stack()
s.push("Dave")
s.push(42)
s.push([3,4,5])
x=s.pop()
y=s.pop()
print x,y
运行是报错,这是python精要上面的例子.报错的内容是AttributeError: 'Stack' object has no attribute 'stack'
_init_(self):
这句,你只打了1个下划线.在init两边要各打2个下划线
__init__这样
DIVE INTO PYTHON怎么样
python 如何判断整除
Python中+=是什么意思
英语翻译monty python 唱的.
python如何表述树形结构
C和PYTHON的区别
python中strip()作用是什么?
有道PYTHON题求解答
Python,C,Perl,and LISP
ord在python是什么意思?怎么使用?
python翻转运算怎样翻啊
用python怎么抽取中间“>”和“
python 判断两线段是否相交
Monty Python and the Holy Grail
学Python,就象学英语一样嘛
python map和reduce的用法
什么是Python,C,Perl,and LISP?
Python, C, Perl, and LISP教我!