【发布时间】:2021-03-03 22:31:42
【问题描述】:
假设我有这个列表列表:
x=[['0', '0', '0', '0', '0', '0'],
['0', '0', '0', '0', '0', '0'],
['0', '0', '0', '0', '0', '0'],
['0', '0', '0', '0', '0', '0']]
现在我得到了
的输入(2,2), (5,4)) (second coordinate represents last pixel where no "1" should be)
which results in
x=[['0', '0', '0', '0', '0', '0'],
['0', '0', '0', '0', '0', '0'],
['0', '0', '1', '1', '1', '0'],
['0', '0', '1', '1', '1', '0']]
for index,i in enumerate(x[3][2:4]):
i ="1"
我不知道为什么这对第一行不起作用...
也欢迎任何想法我可以一次制作矩形:) 提前致谢
(0,0), (1,1)
should give
x=[['1', '0', '0', '0', '0', '0'],
['0', '0', '0', '0', '0', '0'],
['0', '0', '0', '0', '0', '0'],
['0', '0', '0', '0', '0', '0']]
【问题讨论】:
标签: python python-3.x list replace items