This time, we'll bring you python. How to get the maximum value of a single row per column for a two-dimensional matrix, Python to get the two-dimensional matrix of the maximum value of each column of attention to what, the following is the actual case, take a look.
Because there is a small link in the middle of the project needs this function, so write a simple small function, the following is a concrete implementation:
#!usr/bin/env python#encoding:utf-8 ' Author: Yishui Cold City ' def get_max_value (Martix): ' get the maximum value of each column in the matrix ' res_list=[] for J in Range (Len (martix[0)): one_list=[] for i in range (len (Martix)): One_ List.append (int (martix[i][j])) res_list.append (str (max (one_list))) return res_listif name = = ' main ': martix=[[' 1 ', ' 2 ', ' 3 '],[' 3 ', ' 5 ', ' 0 '],[' 5 ', ' 6 ', ' 2 '] [ print get_max_value (Martix)
The results are as follows:
[' 5 ', ' 6 ', ' 3 ']
Believe that you have read the case of this article you have mastered the method, more exciting please pay attention to the PHP Chinese network other related articles!
Recommended reading:
How Python strings are converted to two-dimensional arrays
The object of diff is the virtual Dom