title: 模块概览
模块概览
每个 zerodep 模块都是一个独立的单 .py 文件,可以直接复制到你的项目中使用,运行时无需 pip install。
模块状态
全部模块
网络与通信
| 模块 |
描述 |
可替代 |
性能对标 |
| httpclient |
同步 + 异步 REST 客户端(连接池、代理、认证) |
requests、httpx、urllib3、aiohttp(客户端部分) |
httpx |
| sse |
Server-Sent Events 客户端(自动重连) |
sseclient-py、aiohttp-sse-client、httpx-sse |
httpx-sse |
| httpserver |
异步 HTTP 服务器(装饰器路由、流式响应、静态文件) |
flask(轻量场景)、microdot、bottle、starlette(基础场景)、aiohttp(服务端部分) |
flask / microdot / bottle |
| useragent |
轻量级 Chrome/Edge User-Agent 生成器(含 Client Hints) |
fake-useragent、ua-generator、user-agents |
ua-generator |
| websocket |
RFC 6455 WebSocket 客户端(同步 + 异步) |
websocket-client、websockets |
websockets |
智能体协议
| 模块 |
描述 |
可替代 |
性能对标 |
| jsonrpc |
JSON-RPC 2.0 协议:数据类型、分发器、异步传输 |
jsonrpclib、jsonrpcserver、python-jsonrpc |
jsonrpcserver |
| a2a |
Google A2A 协议:JSON-RPC 2.0、SSE 流式传输、任务管理 |
a2a-sdk、a2a-python |
a2a-python |
| acp |
Anthropic ACP 协议:JSON-RPC 2.0 over stdio、异步客户端/代理 |
acp-python |
acp-python |
| skills |
Agent Skills 运行时:解析、发现、管理、选择技能 |
-- |
-- |
| llmstxt |
llms.txt 解析器与 Markdown URL 候选发现 |
-- |
-- |
| cdp |
Chrome DevTools Protocol 客户端(无头浏览器自动化) |
pychrome、pycdp |
websockets |
序列化
| 模块 |
描述 |
可替代 |
性能对标 |
| xml |
XML ↔ 字典转换器(容错解析、LLM 标签提取) |
xmltodict |
xmltodict |
| yaml |
YAML 解析与序列化(常用子集) |
PyYAML、ruamel.yaml(常用子集) |
PyYAML |
| jsonx |
扩展 JSON 解析(JSONC + JSONL/NDJSON) |
commentjson、jsonlines、ndjson |
commentjson |
| toon |
TOON(面向 Token 的对象表示法)编码器/解码器 |
toon-format |
toon_format |
| frontmatter |
Frontmatter 解析与序列化(YAML/TOML/JSON) |
python-frontmatter |
python-frontmatter |
| protobuf |
Proto3 编解码器(Python dataclass schema) |
protobuf(google)、betterproto |
protobuf |
| multipart |
multipart/form-data 解析与编码器(RFC 7578) |
python-multipart |
python-multipart |
数据验证
| 模块 |
描述 |
可替代 |
性能对标 |
| validate |
TypedDict/dataclass 运行时验证器 + JSON Schema 生成 |
pydantic(验证子集)、cattrs、typeguard、marshmallow |
pydantic |
| jsonschema |
JSON Schema 展平与清理($ref、allOf、anyOf) |
jsonschema(LLM 场景)、allof-merge |
allof-merge |
| semver |
PEP 440 版本解析与比较器 |
packaging(Version 部分)、semver |
packaging |
文本与搜索
| 模块 |
描述 |
可替代 |
性能对标 |
| markdown |
Markdown → HTML 渲染器(CommonMark 子集 + GFM 表格) |
mistune、markdown、markdown-it-py |
mistune |
| soup |
类 BeautifulSoup API 的 HTML 解析器(find、select、CSS 选择器) |
beautifulsoup4(常用子集) |
beautifulsoup4 |
| readability |
文章正文提取器(移植自 Mozilla Readability.js) |
readability-lxml、newspaper3k、trafilatura |
readability-lxml |
| diff |
Unified diff 解析、补丁应用/反转、三方合并 |
unidiff、patch |
unidiff |
| sparse_search |
BM25/BM25+/BM25L/BM25F + TF-IDF 全文搜索(贝叶斯校准、RRF 融合、MMR 多样性) |
rank-bm25、bm25s、whoosh |
rank-bm25 |
| synctex |
SyncTeX 反向搜索解析器(PDF 位置 → 源代码位置) |
-- |
-- |
配置
| 模块 |
描述 |
可替代 |
性能对标 |
| dotenv |
.env 文件解析(load_dotenv, dotenv_values) |
python-dotenv |
python-dotenv |
| config |
统一配置加载器(环境变量、.env、JSON/YAML/TOML/INI) |
python-decouple、dynaconf、environs、pydantic-settings |
python-decouple |
命令行与终端
| 模块 |
描述 |
可替代 |
性能对标 |
| ansi |
ANSI 终端样式:颜色、属性、检测、strip/visible_len |
colorama、termcolor |
-- |
| tabulate |
多种输出样式的表格格式化 |
tabulate、prettytable |
tabulate |
| prompt |
交互式 CLI 提示(confirm、select、text) |
inquirer、questionary |
questionary |
安全
| 模块 |
描述 |
可替代 |
性能对标 |
| aes |
AES 加密:ECB、CBC、CTR、GCM 模式(纯 Python + OpenSSL ctypes) |
pycryptodome(AES 部分)、cryptography(AES 部分) |
pycryptodome |
图像
| 模块 |
描述 |
可替代 |
性能对标 |
| png |
PNG/BMP 图像编解码器(矩阵压缩 API) |
pypng、Pillow(PNG/BMP 子集) |
Pillow |
| qr |
QR Code 生成与终端渲染 |
qrcode、segno |
qrcode |
进程与执行
| 模块 |
描述 |
可替代 |
性能对标 |
| retry |
装饰器式自动重试(退避、抖动、过滤) |
tenacity、retrying、backoff |
tenacity |
| scheduler |
进程内任务调度器(cron、间隔、一次性触发) |
APScheduler、schedule、croniter |
APScheduler |
| runner |
结构化子进程执行(超时升级) |
sh、plumbum(部分) |
-- |
| filelock |
跨平台咨询式文件锁(fcntl/msvcrt) |
filelock |
-- |
存储
| 模块 |
描述 |
可替代 |
性能对标 |
| cache |
内存缓存(TTL、LRU/LFU 淘汰、异步支持) |
cachetools、diskcache(内存部分) |
cachetools |
| persistdict |
持久化字典(JSON / SQLite 后端) |
sqlitedict、diskcache(字典接口) |
-- |
开发工具
| 模块 |
描述 |
可替代 |
性能对标 |
| structlog |
结构化日志与彩色控制台输出 |
structlog、python-json-logger、loguru |
structlog |
| vcs |
Git/Hg/Jujutsu CLI 包装器(diff、status、log、blame) |
GitPython、pygit2(高层接口) |
-- |
| depdetect |
依赖检测与验证 |
pipreqs(部分) |
-- |
模块间依赖关系
大部分 zerodep 模块是完全独立的。以下模块依赖其他 zerodep 模块:
graph LR
a2a --> jsonrpc
acp --> jsonrpc
cdp --> websocket
config --> dotenv
config --> jsonx
config --> yaml
frontmatter --> yaml
qr --> png
readability --> soup
skills --> frontmatter
skills --> sparse_search
sse --> httpclient
vcs --> diff
使用 CLI 工具 时,依赖会自动解析。手动安装时,请确保所有依赖模块都已就位。