queue=[(1,2)] print(len(queue))#输出结果为1 queue.append((3,4)) print(len(queue))#输出结果为2 x,y=queue.pop() print(x,y)#x,y=3,4 queue.append((5,6)) x,y=queue.pop(0) print(x,y)#x,y=1,2 #现在列表里还有(5,6) for x,y in queue: print(x,y)

from collections import deque queue=deque((1,2)) print(len(queue))

这里如果使用双端队列,传入元组就会形成列表
另外有bfs重复入队的问题:
