代码
from bitmap import BitMap
a=[1,5,3,4,7,8,15,6,9]
print(a)
bm=BitMap(max(a))
#print(dir(bm))
print(bm.tostring())
for i in a:
bm.set(i)
print(bm.tostring())
print(bm.nonzero())
执行
% python3 1.py
[1, 5, 3, 4, 7, 8, 15, 6, 9]
0000000000000000
0000000000000010
0000000000100010
0000000000101010
0000000000111010
0000000010111010
0000000110111010
1000000110111010
1000000111111010
1000001111111010
[1, 3, 4, 5, 6, 7, 8, 9, 15]