# Python 如何读取 TOML 配置

URL: https://caijiao.org/how-to/python/config-toml
Source: docs/how-to/python/config-toml.md
Description: Python 如何读取 TOML 配置：Python 3.11+ 可用 tomllib 读取 toml 文件。 包含脚本示例、处理提醒和相关 Python、工具内容入口。

## 快速答案

Python 3.11+ 可用 tomllib 读取 toml 文件。

```py
import tomllib
with open('config.toml', 'rb') as f:
    config = tomllib.load(f)
```

## 使用要点

- 先用一小份测试数据跑通，再处理完整目录或正式数据。
- 把路径、编码和输出文件名提到变量里，便于复用和排查。

## 相关内容

- [Python 问题](/how-to/python/)
- [Python 教程](/python/)
- [Python 文件处理项目](/python/ch11/project-filetool)
- [正则表达式测试工具](/tool/regex-tester)
- [JSON Formatter](/tool/json-formatter)
