我试图在Python中实现一个队列.但是每次我运行我的代码时,我都会收到消息"AttributeError:Queue实例没有属性'队列'"我已经挣扎了一个多小时左右.非常感谢任何帮助.
我的代码:
class Queue: def __int__(self): '''initilize a empty queue''' self.queue = [] def dequeue(self): '''remove and return the last element''' return self.queue.pop() def enqueue(self, val): '''Add element to the end''' self.queue.append(val) def is_empty(self): '''Return True if empty queue''' return len(self.queue) == 0 if __name__== '__main__': q = Queue() for i in range(0,11): q.enqueue(i) while not q.is_empty(): print q.dequeue()
user2357112 .. 6
你拼错__init__
了__int__
.
你拼错__init__
了__int__
.