python3中矩阵如何表示?

图片[1]-python3中矩阵如何表示?-uusu优素-乐高,模型,3d打印,编程

python中表示矩阵的方法:

python中可以利用列表中夹带列表形式表示。

示例:(表示下列矩阵)

使用下面的代码即可:

count=1
a=[]
foriinrange(0,3):
tmp=[]
forjinrange(0,3):
tmp.append(count)
count+=1
a.append(tmp)
printa

结果:

[[1, 2, 3], [4, 5, 6], [7, 8, 9]]

原文来自:https://www.py.cn
© 版权声明
THE END
喜欢就支持一下吧
点赞13 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容