通过list实现堆栈
堆栈就是存储数据的一种数据结构,后存入的数据,会被先取出(先进后出)
>>> stack = [3, 4, 5]
>>> stack.append(6)
>>> stack.append(7)
>>> print (stack)
[3, 4, 5, 6, 7]
>>> print (stack.pop())
7
>>> print (stack)
[3, 4, 5, 6]
>>> print (stack.pop())
6
>>> print (stack.pop())
5
>>> print (stack)
[3, 4]
>>>
通过list实现队列
先进先出
原文:https://www.cnblogs.com/wenm1128/p/11622033.html