numpy中array矩阵转化为list

随机生成矩阵

import  numpy as np
a=np.random.randint(1,9,size=9).reshape((3,3))

打印结果

array([[7, 6, 6],
       [1, 1, 8],
       [2, 4, 8]])

如果想把矩阵转换成list类型

print(a.tolist())

打印结果

[[7, 6, 6], [1, 1, 8], [2, 4, 8]]
发布了19 篇原创文章 · 获赞 0 · 访问量 1153

猜你喜欢

转载自blog.csdn.net/Jinyindao243052/article/details/104029855