字符串基础与进阶
本章讲解 Python 字符串的基础知识和进阶技巧。
章节导航
| 章节 | 文件 | 主题 |
|---|---|---|
| 01 | 01-字符串基础.md | 创建、索引、切片、常用方法 |
| 02 | 02-字符串进阶.md | 编码、正则表达式、实用技巧 |
核心知识点
创建字符串
- 单引号、双引号、三引号
- f-string 格式化
索引和切片
- 正向索引从 0,反向索引从 -1
- 切片
[start:end:step]
常用方法
find/replace/split/joinlower/upper/strip
正则表达式
re.findall() / re.sub() / re.match()- 常用模式:
\d \w \s . * + ?