data = [1, 3, 6, 7, 9, 12, 14, 16, 17, 18, 20, 21, 22, 23, 30, 32, 33, 35] def find_num(data_list,num): print(data_list) if len(data_list)>1: mid=int(len(data_list)/2) if data_list[mid]==num: print('找到了数字%s',num) elif data_list[mid]>num: print('%s在%s的左边'%(num,data_list[mid])) data_list1=data_list[0:mid] find_num(data_list1,num) else: print('%s在%s的右边'%(num,data_list[mid])) data_list2=data_list[mid+1:] find_num(data_list2,num) else: if data_list[0]==num: print('找到了数字%s',num) else: print('%s这个数字不在列表中'%num) data_list=data find_num(data,38)