Python 打印不在循环内打印

Python 打印不在循环内打印,python,printing,Python,Printing,我正在看一个脚本,我想插入一个打印函数,但Python给了我一个名称错误:I未定义 这是密码 for i in xrange(1, len(pts)): # if either of the tracked points are None, ignore # them if pts[i - 1] is None or pts[i] is None: continue # otherwise, compute the thickness of t

我正在看一个脚本,我想插入一个打印函数,但Python给了我一个名称错误:
I
未定义

这是密码

for i in xrange(1, len(pts)):

    # if either of the tracked points are None, ignore
    # them
    if pts[i - 1] is None or pts[i] is None:
        continue

    # otherwise, compute the thickness of the line and
    # draw the connecting lines
    #print ('coord: {}'.format(pts[i]))
    thickness = int(np.sqrt(args["buffer"] / float(i + 1)) * 2.5)
    cv2.line(frame, pts[i - 1], pts[i], (0, 0, 255), thickness)
    #print (pts[i])

# show the frame to our screen
cv2.imshow("Frame", frame)
key = cv2.waitKey(1) & 0xFF

# if the 'q' key is pressed, stop the loop
if key == ord("q"):
    break
我只想打印循环内的
pts[I]
pts[I-1]
元素,但当我尝试插入时:

print (pts[i])
我在
I
上遇到一个名称错误

错误是什么?

请在您的帖子中添加一个。您发布的代码大约有六个
namererror
s,因为我们看不到所有这些变量都是在哪里定义的。另外,这些代码中的大部分可能与您的错误无关(因为
i
在下半部分的任何地方都不会出现),因此可以将其删除。最后,请包括完整的堆栈跟踪。。。它将告诉我们(除其他外)发生
namererror
的确切位置。请参阅“”和该页底部的链接,以获取有关发布完整、可回答、对他人有用的问题的更多建议。请在您的帖子中包含一个。您发布的代码大约有六个
namererror
s,因为我们看不到所有这些变量都是在哪里定义的。另外,这些代码中的大部分可能与您的错误无关(因为
i
在下半部分的任何地方都不会出现),因此可以将其删除。最后,请包括完整的堆栈跟踪。。。它将告诉我们(除其他外)发生
namererror
的确切位置。请参阅“”和该页底部的链接,以获取有关发布完整、可回答、对他人有用的问题的更多建议。