回答此问题可获得 20 贡献值,回答如果被采纳可获得 50 分。
<p>我需要一个坐标列表,以扩大两个新的坐标后,每个原始坐标,以保持一个“绘图”秩序。你知道吗</p>
<p>我已经阅读并理解了一个简单的循环将运行到一个无限循环中,这就是为什么我在第一个列表上使用enumerate并在第二个列表上插入/附加。你知道吗</p>
<p>注意:循环中的“lc”和“rc”用于测试和显示这一点!你知道吗</p>
<pre><code>coords=([100,100,10], [100,101,10], [100,102,10])
print (coords)
coords_n=[]
for idx,val in enumerate(coords):
print (idx,val)
coords_n.insert(idx, [val[0], val[1], val[2]])
lc= [val[0]-50, val[1], val[2]+40, 'lc']
coords_n.insert(idx+1,lc)
rc= [val[0]+50, val[1], val[2]+40, 'rc']
coords_n.insert(idx+2,rc)
print (coords_n)
</code></pre>
<p>结果是一个列表,但顺序不对,新元素位于列表末尾。你知道吗</p>
<pre><code>new List:
0 [100, 100, 10]
1 [100, 101, 10]
2 [100, 102, 10]
3 [50, 102, 50, 'lc']
4 [150, 102, 50, 'rc']
5 [50, 101, 50, 'lc']
6 [150, 101, 50, 'rc']
7 [50, 100, 50, 'lc']
8 [150, 100, 50, 'rc']
</code></pre>
<p>因此,3+4应该位于位置1+2,然后是1和5+6,依此类推。你知道吗</p>