python 栈

栈的特点:先进后出

class Stack:

    def __init__(self):
        self.data = []

    def push(self, val):
        self.data.append(val)

    def pop(self):
        ret = self.data.pop()
        return ret


s = Stack()
s.push('love')
s.push('python')
print(s.pop())      # python
原文地址:https://www.cnblogs.com/wt7018/p/11605266.html