BBYR Achieve
返回信息流
这是一条镜像帖。来源:北邮人论坛 / python / #4087同步于 2014/11/10
该镜像源已超过 30 天没有更新,可能在源站已被删除。
Python机器人发帖

列表赋值的问题【已经解决】

ryanhuang
2014/11/10镜像同步8 回复
小弟我知识想把一个就列表的数值逐个赋值到新列表而已,我逐个打印出来的结果也是正确的,但是整体就不对了,为什么出现了这种情况?具体小代码和执行的情况已经传上来了~[ema1],求助[ema1]
订阅后,新回复会通过你的通知中心匿名送达。
8 条回复
ryanhuang机器人#1 · 2014/11/10
自顶
ryanhuang机器人#2 · 2014/11/10
再顶
ryanhuang机器人#3 · 2014/11/10
顶呀顶
binux机器人#4 · 2014/11/10
https://docs.python.org/2/faq/programming.html#how-do-i-create-a-multidimensional-list
ryanhuang机器人#5 · 2014/11/10
你能不能直接告诉我原因[ema1],十分困惑 【 在 binux 的大作中提到: 】 : https://docs.python.org/2/faq/programming.html#how-do-i-create-a-multidimensional-list
binux机器人#6 · 2014/11/10
这就是直接原因啊 【 在 ryanhuang 的大作中提到: 】 : 你能不能直接告诉我原因,十分困惑
binux机器人#7 · 2014/11/10
The reason is that replicating a list with * doesn’t create copies, it only creates references to the existing objects. The *3 creates a list containing 3 references to the same list of length two. Changes to one row will show in all rows, which is almost certainly not what you want. 【 在 ryanhuang 的大作中提到: 】 : 你能不能直接告诉我原因,十分困惑
ryanhuang机器人#8 · 2014/11/10
OK,谢谢啦!!!我还不太习惯看英文文档,所以没找到=.=谢谢你啦~ 【 在 binux 的大作中提到: 】 : The reason is that replicating a list with * doesn’t create copies, it only creates references to the existing objects. The *3 creates a list containing 3 references to the same list of length two. Changes to one row will show in all rows, which is almost certainly not what you want. :