> For the complete documentation index, see [llms.txt](https://docs.gpmautomate.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gpmautomate.com/automate-zh/cao-zuo-zhi-nan/workflow/exit-loop.md).

# 退出循环

退出循环是强制立即退出当前循环（For 或 While）的操作，无论该循环是否已运行完规定的次数。退出后，系统将继续执行位于该循环块下方的操作。

此操作通常放置在 If 条件语句块中，以处理异常情况或在提前找到所需结果时使用。

#### 实际例子：在找到有效账户时停止检查

假设您使用 For 循环遍历 Excel 文件中的 100 个账户列表，以寻找一个状态为 `"Live"` 的账户。如果第 5 行已经是 "Live" 账户，您就不需要浪费时间继续运行剩下的 95 行。

* 配置方法：
  * 在 For 循环块中，您使用 If 语句进行检查：`如果状态 = "Live"`。
  * 在该 If 块中，您处理获取账户后调用退出循环的操作。
* 结果：系统运行到第 5 行，看到条件成立，立即跳出 For 循环并继续执行下面的操作。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.gpmautomate.com/automate-zh/cao-zuo-zhi-nan/workflow/exit-loop.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
