def _bisect_value(a, x, priority='right'):
    '\n    返回 bisect_right() 取得下标对应的值，当插入点距离前后元素距离相等，priority 表示优先返回右边的值还是左边的值\n    a: 必须是已经排序好（升序排列）的 list\n    bisect_right : Return the index where to insert item x in list a, assuming a is sorted.\n    '
    assert (priority in ['left', 'right'])
    insert_index = bisect_right(a, x)
    if (0 < insert_index < len(a)):
        left_dis = (x - a[(insert_index - 1)])
        right_dis = (a[insert_index] - x)
        if (left_dis == right_dis):
            mid_index = ((insert_index - 1) if (priority == 'left') else insert_index)
        elif (left_dis < right_dis):
            mid_index = (insert_index - 1)
        else:
            mid_index = insert_index
    else:
        assert ((insert_index == 0) or (insert_index == len(a)))
        mid_index = (0 if (insert_index == 0) else (len(a) - 1))
    return a[mid_index]
返回 bisect_right() 取得下标对应的值，当插入点距离前后元素距离相等，priority 表示优先返回右边的值还是左边的值
a: 必须是已经排序好（升序排列）的 list
bisect_right : Return the index where to insert item x in list a, assuming a is sorted.
def _bisect_value(a, x, priority='right'):
    '\n    返回 bisect_right() 取得下标对应的值，当插入点距离前后元素距离相等，priority 表示优先返回右边的值还是左边的值\n    a: 必须是已经排序好（升序排列）的 list\n    bisect_right : Return the index where to insert item x in list a, assuming a is sorted.\n    '
    assert (priority in ['left', 'right'])
    insert_index = bisect_right(a, x)
    if (0 < insert_index < len(a)):
        left_dis = (x - a[(insert_index - 1)])
        right_dis = (a[insert_index] - x)
        if (left_dis == right_dis):
            mid_index = ((insert_index - 1) if (priority == 'left') else insert_index)
        elif (left_dis < right_dis):
            mid_index = (insert_index - 1)
        else:
            mid_index = insert_index
    else:
        assert ((insert_index == 0) or (insert_index == len(a)))
        mid_index = (0 if (insert_index == 0) else (len(a) - 1))
    return a[mid_index]