折半查找
def bin_search(items, key):
'''折半查找'''
start, end = 0, len(items) - 1
while start <= end:
mid = (start + end) // 2
if key > items[mid]:
start = mid + 1
elif key < items[mid]:
end = mid - 1
else:
return mid
return -1
print(bin_search([3.2,2,10,3,1,45,90,0], 3))