d = collections.deque([]) # 创建双端队列
d.append('a') # 在最右边添加一个元素,此时 d=deque('a')
d.appendleft('b') # 在最左边添加一个元素,此时 d=deque(['b', 'a'])
d.extend(['c','d']) # 在最右边添加所有元素,此时 d=deque(['b', 'a', 'c', 'd'])
collections.deque
猜你喜欢
转载自www.cnblogs.com/pjishu/p/10545734.html
今日推荐
周排行