python 栈

#模拟栈结构
stack = []

#压栈(向栈里存数据)
stack.append("A")
print(stack)
stack.append("B")
print(stack)
stack.append("C")
print(stack)



#出栈(在栈里取数据)
res1 = stack.pop()
print("res1 =", res1)
print(stack)
res2 = stack.pop()
print("res2 =", res2)
print(stack)
res3 = stack.pop()
print("res3 =", res3)
print(stack)
posted @ 2020-02-08 10:11  i勤能补拙  阅读(225)  评论(0编辑  收藏  举报