標籤:ext ash max _for __add__ init pop sub __iter__
[‘__add__‘, ‘__bool__‘, ‘__class__‘, ‘__contains__‘, ‘__copy__‘, ‘__delattr__‘, ‘__delitem__‘, ‘__dir__‘, ‘__doc__‘, ‘__eq__‘, ‘__format__‘, ‘__ge__‘, ‘__getattribute__‘, ‘__getitem__‘, ‘__gt__‘, ‘__hash__‘, ‘__iadd__‘, ‘__imul__‘, ‘__init__‘, ‘__init_subclass__‘, ‘__iter__‘, ‘__le__‘, ‘__len__‘, ‘__lt__‘, ‘__mul__‘, ‘__ne__‘, ‘__new__‘, ‘__reduce__‘, ‘__reduce_ex__‘, ‘__repr__‘, ‘__reversed__‘, ‘__rmul__‘, ‘__setattr__‘, ‘__setitem__‘, ‘__sizeof__‘, ‘__str__‘, ‘__subclasshook__‘, ‘append‘, ‘appendleft‘, ‘clear‘, ‘copy‘, ‘count‘, ‘extend‘, ‘extendleft‘, ‘index‘, ‘insert‘, ‘maxlen‘, ‘pop‘, ‘popleft‘, ‘remove‘, ‘reverse‘, ‘rotate‘]
from collections import dequed = deque()print(dir(d))d.append(1)d.append(10)d.appendleft(1)print(d)# deque([1, 1, 10])# d.clear()# print(d)# deque([])b = d.copy()# print(b)# deque([1, 1, 10])# d.extend(b)# print(d)# deque([1, 1, 10, 1, 1, 10])# d.extendleft(b)# print(d)# deque([10, 1, 1, 1, 1, 10, 1, 1, 10])print(d.count(1))# 2print(d.index(10))# 2d.insert(10,15)# d.remove(1)# deque([1, 10, 15])print(d)d.rotate(3)# deque([1, 10, 15, 1])print(d)
from queue import Queueq = Queue()q.put(‘123‘)q.put(‘456‘)print(q.qsize())print(q.get_nowait())print(q.get_nowait())print(q.qsize())# 2# 123# 456# 0
Python實戰之雙向隊列deque/queue學習筆記及簡單練習