[popexizhi:
py2,py3都支持啊,mark deque竟然可以popleft 和 appendleft
]
>>> from collections import deque >>> q = deque(maxlen=3) >>> q = deque() >>> q.append(1) >>> q.append(2) >>> q.append(3) >>> q deque([1, 2, 3]) >>> q.appendleft(3)>>> q deque([3, 1, 2, 3]) >>> q.pop() 3 >>> q deque([3, 1, 2]) >>> q.popleft() 3 >>> q deque([1, 2])
没有评论:
发表评论