[‘__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 deque d = 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)) # 2 print(d.index(10)) # 2 d.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 Queue q = 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
时间: 2024-10-28 16:01:49