队列&堆栈

# 1、队列:FIFO先进先出
l=[]
#入队操作
l.append('first')
l.append('second')
l.append('third')
print(l)#['first', 'second', 'third']
#出队操作
print(l.pop(0))#first
print(l.pop(0))#second
print(l.pop(0))#third

#2、堆栈:LIFO后进先出
l=[]
#入栈操作
l.append('first')
l.append('second')
l.append('third')
print(l)#['first', 'second', 'third']
#出队操作
print(l.pop())#third
print(l.pop())#second
print(l.pop())#first
原文地址:https://www.cnblogs.com/guojieying/p/13305510.html