在一个数字集合中查找某个值存不存在
1 data = range(0,100000000) 2 3 # data = [1,3,5,10,11,12,14,17,19,19,20] 4 5 def binary_search(datasets,find_num): 6 if len(datasets) >0: 7 middle_pos = int(len(datasets)/2) 8 if datasets[middle_pos] == find_num: 9 #find it 10 print("Find num:",datasets[middle_pos]) 11 elif datasets[middle_pos] > find_num: 12 #data in left side 13 print("