This time to bring you a list in Python, arrays, matrices to convert each other's methods, in Python list, array, matrix to each other to the attention of the conversion, the following is the actual case, together to see.
Through the code familiarity process:
#-*-Coding:utf-8-*-from numpy import *a1 =[[1,2,3],[4,5,6]] #列表print (' A1: ', A1) # (' A1: ', [[1, 2, 3], [4, 5, 6]]) A2 = a Rray (A1) #列表-----> Array Print (' A2: ', A2) # (' A2: ', Array ([[[1, 2, 3],[4, 5, 6]])) A3 = Mat (A1) #列表----> Matrix print (' A3: ', A3) # (' A3: ', Matrix ([[1, 2, 3],[4, 5, 6]])) A4 = a3.tolist () #矩阵---> list print (' A4: ', A4) # (' A4: ', [[1, 2, 3], [4, 5, 6]) print (a1 = = a4) #Truea5 = a2.tolist () #数组---> List print (' A5: ', A5) # (' A5: ', [[1, 2, 3], [4, 5, 6]) Print (A5 = A1) #T RUEA6 = Mat (a2) #数组---> Matrix print (' A6: ', A6) # (' A6: ', Matrix ([[[1, 2, 3],[4, 5, 6]]) print (A6 = A3) #[[true True true][ True true True]]a7 = Array (a3) #矩阵---> Array print (' A7: ', A7) # (' A7: ', array ([[[1, 2, 3],[4, 5, 6]]) print (a7 = a2) #[[Tr UE true true][true True true]]################################################################## #a1 =[1,2,3,4,5,6] # List print (' A1: ', A1) # (' A1: ', [1, 2, 3, 4, 5, 6]) a2 = array (a1) #列表-----> Array Print (' A2: ', A2) # (' A2: ', Array ([1, 2, 3, 4 , 5, 6])) A3 = Mat (A1) #列表----> Matrix print (' A3: ', A3) # (' A3: ', Matrix ([[[1, 2, 3, 4, 5, 6])) A4 = a3.tolist () #矩阵---> list print (' A4: ', A4) # (' A4: ', [[1, 2, 3, 4, 5, 6]] #注意!! There are different print (A1 = = a4) #Falsea8 = a3.tolist () [0] #矩阵---> List print (' A8: ', A8) # (' A8: ', [1, 2, 3, 4, 5, 6]) #注意!! There are different print (A1 = = a8) #Truea5 = a2.tolist () #数组---> List print (' A5: ', A5) # (' A5: ', [1, 2, 3, 4, 5, 6]) Print (A5 = A1) #Truea6 = Mat (A2) #数组---> Matrix print (' A6: ', A6) # (' A6: ', Matrix ([[[1, 2, 3, 4, 5, 6])) print (A6 = A3) #[[true True True Tr UE true]]a7 = Array (a3) #矩阵---> Array print (' A7: ', A7) # (' A7: ', Array ([[1, 2, 3, 4, 5, 6])) Print (a7 = a2) #[[true True T Rue true True]]
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 to assign a uniform value to an array element in a NumPy
How to use the multiplication of numpy arrays and matrices