小编Sha*_*man的帖子

有没有办法检测Python中的循环是否停止

我试图检测我的循环何时停止,以便我可以使用 if 语句说:如果“循环已停止”:print(text)

代码:

faces = detector(gray)

for face in faces:

    x, y = face.left(), face.top()
    x1, y1 = face.right(), face.bottom()
    rectangle = cv2.rectangle(frame, (x, y), (x1, y1), (0, 255, 0), 2)

    if "the loop has stopped":
        cv2.putText(frame, "Asleep", (50, 150), font, 7, (0, 0, 255))
Run Code Online (Sandbox Code Playgroud)

python for-loop if-statement

3
推荐指数
1
解决办法
1799
查看次数

标签 统计

for-loop ×1

if-statement ×1

python ×1