bisect.bisect_left和bisect.bisect_right,返回有序新元素在有序序列中的位置
注意:当序列中存在被插入数时,bisect.bisect_left和bisect.bisect_right的结果才有差异
array = [1, 2, 3, 3, 4, 5]
index = bisect.bisect_left(array, 3)
print(index)
index = bisect.bisect_right(array, 3)
print(index)
输出
2
4