# SyntaxError: 'await' 在 async 函数之外

- **ID:** `python/asyncio-await-outside-async`
- **领域:** python
- **类别:** runtime_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

在模块级别或非 async def 内使用 await；await 仅在 async def 内有效（或 notebook/repl 中顶层特殊支持）。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.5+ | active | — | — |

## 解决方案

1. **** (97% 成功率)
   ```
   import asyncio

async def main():
    await some_coro()

asyncio.run(main())
   ```
2. **** (93% 成功率)
   ```
   import asyncio
result = asyncio.run(some_coro())
   ```

## 无效尝试

- **** — This is a parser-level SyntaxError, not a type error; comments cannot suppress it. (95% 失败率)
- **** — SyntaxError occurs at compile time before any except block is entered. (95% 失败率)
