队列
定义:
>>> q = []
>>> q.append(1)
>>> q.append(2)
>>> q.append(3)
>>> q.pop(0)
1
>>> q.pop(0)
2
队列顶端
>>> q[0]
3
>>> not q
False
>>> if q:
print 'not empty'
not empty
栈
定义:
>>> s = []
>>> s.append(1)
>>> s.append(2)
>>> s.append(3)
>>> s.pop()
3
>>> s.pop()
2
>>> s[-1]
1
>>> not s
False
>>> if s:
print 'not empty'
not empty