python代码实现

import numpy as np

def maxmin(array):  #求每列的最值
    maxlist=[]
    minlist=[]
    for i in range(len(array[0])):#行数
        col=[]
        for j in range(len(array)):#列数
            col.append(array[j][i])
        maxlist.append(max(col))
        minlist.append(min(col))
    return maxlist,minlist

if __name__=="__main__":
    array = np.array([[1, 3, 4],
                      [0, 1, 4],
                      [2, 5, 6],
                      [2, 4, 4]])
    maxlist,minlist=maxmin(array)
    print(maxlist)#输出[2,5,6]
    print(minlist)#输出[0,1,4]