你需要在第二次返回时签上标签。尝试:
key: int) -> int: if left <= right: if array[left] == key: return left else: binary_search_recursive(array, left + 1, right, key) return -1 #Moved to the right.