仿写自博客 http://www.cnblogs.com/chongyou/p/7099326.html
class Node(object):
def __init__(self,val):
self.value = val
self.next = None
class myquene(object):
def __init__(self):
self.first = None
self.last = None
# self.next = None
def enter(self,x):
n = Node(x)
if self.first ==None:
self.first = n
self.last = self.first
else:
self.last.next = n
self.last = n
def quit(self):
if not self.first:
return None
else:
tmp = self.first.value
self.first = self.first.next
return tmp
def quit_all(self):
retlist = []
while self.first!=None:
retlist.append(self.first.value)
self.first = self.first.next
return retlist
if __name__ =="__main__":
q = myquene()
q.enter('厉智')
q.enter('徐晓冬')
q.enter('陈培昌')
q.enter('程劲')
print(q.quit_all())