添加行的直接方法是使用:
line.ud["line"].points += [touch.x, touch.y]
我想问是否可以从行中删除点。我实际要做的是制作一条线,该线随着鼠标的移动而移动。
我想 points
是列表的列表。
为了简化,我将用points
变量将您的观点结构置于您的点结构。
-
您可以删除指定点(必须在列表中(
points = [[1,2], [3,4], [5,6]] points.remove([3,4]) print(points) # [[1,2], [5,6]]
-
您可以在列表中弹出
i
-点数points = [[1,2], [3,4], [5,6]] removed_point = points.pop(1) print(removed_point) # [3,4] print(points) # [[1,2], [5,6]]
-
您可以切成列表以摆脱不需要的点
points = [[1,2], [3,4], [5,6]] points = points[:1] + points[2:] print(points) # [[1,2], [5,6]]