寻找两个有序数组的中位数
def func(num1,num2): ret=0 result=[] result.extend(num1) result.extend(num2) result.sort() if len(result)%2==0: index=int(len(result)/2) ret=(result[index-1]+result[index])/2 else: index=int(len(result)/2) ret=result[index] return ret ret=func([1,2],[3,4]) print(ret)