在嵌套循环中构造坐标

时间:2016-11-14 05:01:23

标签: python loops

我想在循环中构造以下坐标:

 (65, 570)
 (865, 570)
 (65, 1090)
 (865, 1090)
 (65, 1610)
 (865, 1610)

这是我的代码:

pos_y = 570
pos_x = 65
for fila in range(len(pics)):
    pos_x = 65
    for columna in range(len(pics)-1):
        print(pos_x, pos_y)
        pos_y = 570
        pos_x = pos_x + 800

问题是我的循环,不更新pos_y的值。我做错了什么?输出:

65 570
865 570
65 570
865 570
65 570
865 570

1 个答案:

答案 0 :(得分:1)

pos_y = 570
for fila in range(len(pics)):
    pos_x = 65
    for columna in range(len(pics)-1):
        print(pos_x, pos_y)
        pos_x += 800
    pos_y += 520