文本处理服务¶
本章介绍的模块提供了广泛的字符串操作和其他文本处理服务。
在 二进制数据服务 之下描述的  codecs 模块也与文本处理高度相关。 此外也请参阅 Python 内置字符串类型的文档 文本序列类型 --- str。
- string--- 常见的字符串操作
- re--- 正则表达式操作
- difflib--- 计算差异的辅助工具- Differ
- HtmlDiff
- context_diff()
- get_close_matches()
- ndiff()
- restore()
- unified_diff()
- diff_bytes()
- IS_LINE_JUNK()
- IS_CHARACTER_JUNK()
- SequenceMatcher 对象- SequenceMatcher- SequenceMatcher.set_seqs()
- SequenceMatcher.set_seq1()
- SequenceMatcher.set_seq2()
- SequenceMatcher.find_longest_match()
- SequenceMatcher.get_matching_blocks()
- SequenceMatcher.get_opcodes()
- SequenceMatcher.get_grouped_opcodes()
- SequenceMatcher.ratio()
- SequenceMatcher.quick_ratio()
- SequenceMatcher.real_quick_ratio()
 
 
- SequenceMatcher 的示例
- Differ 对象
- Differ 示例
- difflib 的命令行接口
- ndiff 示例
 
- textwrap--- 文本自动换行与填充- wrap()
- fill()
- shorten()
- dedent()
- indent()
- TextWrapper- TextWrapper.width
- TextWrapper.expand_tabs
- TextWrapper.tabsize
- TextWrapper.replace_whitespace
- TextWrapper.drop_whitespace
- TextWrapper.initial_indent
- TextWrapper.subsequent_indent
- TextWrapper.fix_sentence_endings
- TextWrapper.break_long_words
- TextWrapper.break_on_hyphens
- TextWrapper.max_lines
- TextWrapper.placeholder
- TextWrapper.wrap()
- TextWrapper.fill()
 
 
- unicodedata--- Unicode 数据库
- stringprep--- 因特网字符串预备
- readline--- GNU readline 接口
- rlcompleter--- GNU readline 的补全函数