标签:from 列表 list bsp nump 转换 imp 数组 lis
将数组或者矩阵转换成列表,如下:
>>> from numpy import *
>>> a1 = [[1,2,3],[4,5,6]] #列表
>>> a2 = array(a1) #数组
>>> a2
array([[1, 2, 3],
[4, 5, 6]])
>>> a3 = mat(a1) #矩阵
>>> a3
matrix([[1, 2, 3],
[4, 5, 6]])
>>> a4 = a2.tolist()
>>> a4
[[1, 2, 3], [4, 5, 6]]
>>> a5 = a3.tolist()
>>> a5
[[1, 2, 3], [4, 5, 6]]
>>> a4 == a5
True
标签:from 列表 list bsp nump 转换 imp 数组 lis
原文地址:https://www.cnblogs.com/Aaron12/p/9042687.html