如果我使用 python 模块 queue.Queue,我希望能够使用不弹出原始队列或创建新队列对象的方法打印出内容。
我曾尝试研究获取然后将内容放回原处,但这成本太高。
# Ideally it would look like the following
from queue import Queue
q = Queue()
q.print()
q.put(1)
q.print()
>> [] # Or something like this
>> [1] # Or something like this
原文由 Interlooper 发布,翻译遵循 CC BY-SA 4.0 许可协议
这对你有用吗?