使用collections.deque:
>>> import collections>>> q = collections.deque(["herp", "derp", "blah", "what", "da.."])>>> q.appendleft('wuggah')>>> q.pop()'da..'>>> qdeque(['wuggah', 'herp', 'derp', 'blah', 'what'])
使用collections.deque:
>>> import collections>>> q = collections.deque(["herp", "derp", "blah", "what", "da.."])>>> q.appendleft('wuggah')>>> q.pop()'da..'>>> qdeque(['wuggah', 'herp', 'derp', 'blah', 'what'])