【python】队列

来源:http://www.cnblogs.com/yupeng/p/3413852.html

 

关于队列
>>> from collections import deque
>>> queue = deque(["Eric", "John", "Michael"])
>>> queue.append("Terry")           # Terry arrives
>>> queue.append("Graham")          # Graham arrives
>>> queue.popleft()                 # The first to arrive now leaves
'Eric'
>>> queue.popleft()                 # The second to arrive now leaves
'John'
>>> queue                           # Remaining queue in order of arrival
deque(['Michael', 'Terry', 'Graham'])
posted @ 2016-07-26 18:59  匡子语  阅读(184)  评论(0编辑  收藏  举报