在数组中查找符合的数字,并返回序列号
def find(list, item):
low =0
hith =len(list)-1
while low <= hith:
mid =int((low + hith) /2)
if list[mid] == item:
return mid
if list[mid] < item:
low = mid +1
else:
hith = hith -1
return None
list = [1,2,3,4,5,6,7,8,9]
item =7
print(find(list, item))
来源:博客园
作者:M_派森
链接:https://www.cnblogs.com/April-Chou-HelloWorld/p/11563548.html