相思资源网 Design By www.200059.com

实例如下所示:

>from compiler.ast import flatten

>X
matrix([[ 1, 17, 13, 221, 289, 169],
 [ 1, 17, 14, 238, 289, 196],
 [ 1, 17, 15, 255, 289, 225],
 [ 1, 18, 13, 234, 324, 169],
 [ 1, 18, 14, 252, 324, 196],
 [ 1, 18, 15, 270, 324, 225],
 [ 1, 19, 13, 247, 361, 169],
 [ 1, 19, 14, 266, 361, 196],
 [ 1, 19, 15, 285, 361, 225]])
>x = X.tolist()
>x
[[ 1, 17, 13, 221, 289, 169],
 [ 1, 17, 14, 238, 289, 196],
 [ 1, 17, 15, 255, 289, 225],
 [ 1, 18, 13, 234, 324, 169],
 [ 1, 18, 14, 252, 324, 196],
 [ 1, 18, 15, 270, 324, 225],
 [ 1, 19, 13, 247, 361, 169],
 [ 1, 19, 14, 266, 361, 196],
 [ 1, 19, 15, 285, 361, 225]]
>xx = flatten(x)
>xx
[1,
 17,
 13,
 221,
 289,
 169,
 1,
 17,
 14,
 238,
 289,
 196,
 1,
 17,
 15,
 255,
 289,
 225,
 1,
 18,
 13,
 234,
 324,
 169,
 1,
 18,
 14,
 252,
 324,
 196,
 1,
 18,
 15,
 270,
 324,
 225,
 1,
 19,
 13,
 247,
 361,
 169,
 1,
 19,
 14,
 266,
 361,
 196,
 1,
 19,
 15,
 285,
 361,
 225]

以上这篇python矩阵转换为一维数组的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

标签:
python,矩阵,一维数组

相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com

评论“python矩阵转换为一维数组的实例”

暂无python矩阵转换为一维数组的实例的评论...