栈栈结构
模拟栈结构
stack = []
stack.append("A")
print(stack)
stack.append("B")
print(stack)
stack.append("C")
print(stack)
res = stack.pop()
print("res = ", res)
print(stack)
res2 = stack.pop()
print("res2 = ", res2)
print(stack)
res3 = stack.pop()
print("res3 = ", res3)
print(stack)
队列
import collections
queue = collections.deque()
print(queue)
queue.append("A")
print(queue)
queue.append("B")
print(queue)
queue.append("C")
print(queue)
res1 = queue.popleft()
print("res1 = ", res1)
print(queue)
res2 = queue.popleft()
print("res2 = ", res2)
print(queue)
res3 = queue.popleft()
print("res1 = ", res3)
print(queue)