主页
Python
Python heapq 模块
demo_ref_module_heapq_basic
运行 ❯
×
更改方向
保存代码
更改主题
import heapq h = [] heapq.heappush(h, 3) heapq.heappush(h, 1) heapq.heappush(h, 2) print([heapq.heappop(h) for _ in range(3)])
[1, 2, 3]