每天CookBook之Python-071
- 使用堆排序合并序列
import heapq
a = [1, 4, 7, 10]
b = [2, 5, 6, 11]
for c in heapq.merge(a, b):
    print(c)
out
1
2
4
5
6
7
10
11
import heapq
a = [1, 4, 7, 10]
b = [2, 5, 6, 11]
for c in heapq.merge(a, b):
    print(c)
out
1
2
4
5
6
7
10
11
