标准库知识体系概览
为什么要学标准库
Python 的标准库被称为"batteries included"(自带电池),提供了极其丰富的工具。熟练使用标准库可以大幅减少第三方依赖,写出更 Pythonic 的代码。
核心模块分类
知识点关联
| 文档 | 核心内容 | 面试重要度 |
|---|---|---|
| collections | defaultdict、Counter、deque、namedtuple | ⭐⭐⭐⭐⭐ |
| itertools | chain、product、groupby、组合排列 | ⭐⭐⭐⭐ |
| functools | lru_cache、partial、reduce、singledispatch | ⭐⭐⭐⭐ |
| pathlib | Path 操作、文件遍历 | ⭐⭐⭐ |
| typing | 类型注解、Generic、Protocol | ⭐⭐⭐⭐ |
| dataclasses | @dataclass、field、Pydantic 对比 | ⭐⭐⭐⭐ |
| 正则表达式 | 常用模式、分组、贪婪/非贪婪 | ⭐⭐⭐ |