# 流式输出
<subtitle>在命令执行过程中实时流式输出 stdout 和 stderr。</subtitle>

要在命令执行时流式输出其结果，请将 `on_stdout`、`on_stderr` 回调传递给 `commands.run()` 方法。

```python
from ucloud_sandbox import Sandbox

sandbox = Sandbox.create()

result = sandbox.commands.run('echo hello; sleep 1; echo world', on_stdout=lambda data: print(data), on_stderr=lambda data: print(data))
print(result)
```
