If you want to convert a string list to an int list (each string in the list goes to int), for example
[python] [' 0 ', ' 1 ', ' 2 ']--[0,1,2] can be used: [Python] [int (x) for x in list] Or use the map operation: Map (func, list) apply Func to each element in the list. [Python] map (int, list) assumes a 2-dimensional array (implemented with list): [python] list = [[0,1,2],[3,1,4]] If you want to get the sum of each line, you can use the following two ways: [python] >>> list = [[[0,1,2],[3,1,4]] >>> [sum (x) for x in list] [3, 8] >>> map (sum,list) [3, 8] if you want to get the sum of each column, you need to unzip the list with a zip (*list) to get a list of tuples, Where the I tuple contains the I element for each line: [python] >>> list = [[[0,1,2],[3,1,4]] >>> zip (*list) [(0, 3), (1 , 1), (2, 4)] >>> [sum (x) for x in Zip (*list)] [3, 2, 6] >>> map (sum,zip (*list))   ; [3, 2, 6] The following example is about zip and unzip (actually zip and * together) how work:[python] >>> x=[1,2,3] >>> y=[4,5,6] >>> zipped = Zip (x, y) >>> zipped [(1, 4), (2, 5), (3, 6)] >>> X2,y2=zip(*zipped) >>> x2 (1, 2, 3) >>> y2 (4, 5, 6) >>> X3,y3=map (List,zi P (*zipped)) >>> X3 [1, 2, 3] >>> y3 [4, 5, 6]
Go! Turn the!!!