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)
![测试结果](https://uploadfiles.nowcoder.com/images/20200605/4319876_1591345547070_2D73A899C744FC5AAF43CEA8339142E4 "图片标题")
from collections import deque queue=deque((1,2)) print(len(queue))
![测试结果](https://uploadfiles.nowcoder.com/images/20200605/4319876_1591345688791_F639DA0ADFAD4517231FCFBF6115EB98 "图片标题")
这里如果使用双端队列,传入元组就会形成列表
另外有bfs重复入队的问题:
![bfs超时](https://uploadfiles.nowcoder.com/images/20200605/4319876_1591345808742_5B341681B00EAB3E3B62DBB82E4AFB1B "图片标题")