Hi i'm trying to get a set of points from matplotlib.pyplot.ginput. my idea is to save points in a list while the actuaPoint!=lastPoint
is there a way to do it something like:
lastPoint = None
pointList = []
actualPoint = plt.ginput(1)
while (actualPoint=plt.input()) != lastPoint:
pointList.append(actualPoint)
lastPoint= actualPoint
? resuming i'm trying to know if there's a way to do the variable assignment inside the while statement
You need to use an assignment expression , using the :=
operator.
point, = pointList = [plt.ginput(1)]
while (next_point := plt.input()) != point:
pointList.append(next_point)
point = next_point
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.