Python 中的二维数组?
我如何对列表执行“for every”命令,所以我想循环遍历列表中的每个项目!
How would I do a "for every" command for a list, so I want to loop through it for every item in the list!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
提出一个简短的问题,得到一个简短的答案:
请注意,通常当人们说“数组”时,他们指的是 C 具有的平面数据结构:内存中的相邻单元块。特别是,您不能追加到数组。 Python 的
list
类型是数组和列表的混合体,您可以追加和弹出,也可以索引。 (我相信这是一个动态调整大小的数组。)Ask a short question, get a short answer:
Note that typically when people say "array" they mean the flat data-structure that C has: a block of adjacent cells in memory. In particular, you can't append to an array. Python's
list
type is a cross between an array and a list in that you can append and pop but also index. (I believe it's a dynamically resizing array.)您修改后的问题的答案是:
这就是您所寻找的一切吗?
The answer to your revised question is:
Is this all you were looking for?
对二维数组的
http: //www.stev.org/post/2012/02/22/Python-2d-Arrays-dont-work.aspx
Try something like this for 2d array's
http://www.stev.org/post/2012/02/22/Python-2d-Arrays-dont-work.aspx