# 栈 # 特点: 先进后出 # class StackFullException(Exception): # pass # # class StackEmptyException(Exception): # pass # # class Stack: # # def __init__(self, size): # self.size = size # self.lst = [] # 存放数据的列表 # self.top = 0 # 栈顶指针 # # # 入栈 # def push(self, el): # if self.top >= self.size: # raise StackFullException("your stack is full!!!!!") # self.lst.insert(self.top, el) # 放元素 # self.top += 1 # 栈顶指针向上移动一下 # # # 出栈 # def pop(self): # if self.top == 0: # raise StackEmptyException("your stack is empty!!!!!") # self.top-=1 # el = self.lst[self.top] # return el # # s = Stack(6) # s.push("宝宝") # s.push("我还") # s.push("记得") # s.push("你") # s.push("刚刚") # s.push("说的话") # print(s.pop()) # print(s.pop()) # print(s.pop()) # print(s.pop()) # print(s.pop()) # print(s.pop()) # import queue # q = queue.Queue() # q.put("李嘉诚1") # q.put("李嘉诚2") # q.put("李嘉诚3") # q.put("李嘉诚4") # q.put("李嘉诚5") # # print(q.get()) # print(q.get()) # print(q.get()) # print(q.get()) # print(q.get()) # from collections import deque # # d = deque() # 创建双向队列 # d.append("宝宝") # 在右侧添加 # d.append("no") # d.append("way") # d.append("哈哈") # d.appendleft("娃哈哈") # 在左边添加 # d.appendleft("爽歪歪") # d.appendleft("优酸乳") # # # print(d.pop()) # 从右边拿数据 # print(d.pop()) # 从右边拿数据 # print(d.pop()) # 从右边拿数据 # print(d.pop()) # 从右边拿数据 # print(d.popleft()) # 从左边拿数据 # print(d.popleft()) # 从左边拿数据 # print(d.popleft()) # 从左边拿数据 # #