对于一个实验,我想创建多个矩形,其中一个是目标矩形。 因此我创建了一个x,y坐标的列表
xy_list = xy_circle(8, 200)
random.shuffle(xy_list)
以及rarget矩形的代码,x,y坐标xy\u列表[0]
target_rectangle = visual.Rect(win=mywin4, width=45, height=90, pos(xy_list[0]), lineColor='white', fillColor='blue', ori=orientations_list[1])
target_rectangle.draw()
为了节省一些时间和空间,我想使用xy-U列表的索引1-7为干扰物矩形创建一个for循环。但是我对Python还不熟悉,所以我不知道该怎么做。谁能给我个提示吗?非常感谢。你知道吗
for x, y in xy_list:
distractor_rectangle = visual.Rect(win=mywin4, width=45, height=90, pos=(x, y), fillColor='white')
distractor_rectangle.draw()
您可以使用
range()
遍历索引,并通过xy_list[index]
访问它们:相关问题 更多 >
编程相关推荐