如何使用for-loop从列表列表(矩阵)获取每个元素
M = [[0,1,0,1],[0,0,1,0]]
for i in range(len(M)):
print(M[i][i])
如何在我不记得的python循环中的列表中获取元素的元素
,它似乎可以与m [i] [0]或m [i] [1]一起使用,但是我想在一个环形
M = [[0,1,0,1],[0,0,1,0]]
for i in range(len(M)):
print(M[i][i])
How to get the element of an element in a list within a loop in python
I can't remember, it's seems to work with M[i][0] or M[i][1] but I want to do it within a loop
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
要在单独的行上查看所有数字:
To see all the numbers on separate lines:
另外,您可以使用索引使用
[:]
访问列表的操作员:Also, you can use indexes to traverse the elements using
[:]
accessing operator for lists:可以使用列表理解是需要输出的列表
Can be done using list comprehension is required output is list