文本处理服务
************

本章介绍的模块提供了广泛的字符串操作和其他文本处理服务。

在 二进制数据服务 之下描述的  "codecs" 模块也与文本处理高度相关。 此外
也请参阅 Python 内置字符串类型的文档 文本序列类型 --- str。

* "string" --- 常见的字符串操作

  * 字符串常量

    * "ascii_letters"

    * "ascii_lowercase"

    * "ascii_uppercase"

    * "digits"

    * "hexdigits"

    * "octdigits"

    * "punctuation"

    * "printable"

    * "whitespace"

  * 自定义字符串格式化

    * "Formatter"

      * "format()"

      * "vformat()"

      * "parse()"

      * "get_field()"

      * "get_value()"

      * "check_unused_args()"

      * "format_field()"

      * "convert_field()"

  * 格式字符串语法

    * 格式规格迷你语言

    * 格式示例

  * 模板字符串

    * "Template"

      * "substitute()"

      * "safe_substitute()"

      * "is_valid()"

      * "get_identifiers()"

      * "template"

  * 辅助函数

    * "capwords()"

* "re" --- 正则表达式操作

  * 正则表达式语法

  * 模块内容

    * 标志

      * "RegexFlag"

      * "A"

      * "ASCII"

      * "DEBUG"

      * "I"

      * "IGNORECASE"

      * "L"

      * "LOCALE"

      * "M"

      * "MULTILINE"

      * "NOFLAG"

      * "S"

      * "DOTALL"

      * "U"

      * "UNICODE"

      * "X"

      * "VERBOSE"

    * 函数

      * "compile()"

      * "search()"

      * "match()"

      * "fullmatch()"

      * "split()"

      * "findall()"

      * "finditer()"

      * "sub()"

      * "subn()"

      * "escape()"

      * "purge()"

    * 异常

      * "PatternError"

        * "msg"

        * "pattern"

        * "pos"

        * "lineno"

        * "colno"

  * 正则表达式对象 （正则对象）

    * "Pattern"

    * "search()"

    * "match()"

    * "fullmatch()"

    * "split()"

    * "findall()"

    * "finditer()"

    * "sub()"

    * "subn()"

    * "flags"

    * "groups"

    * "groupindex"

    * "pattern"

  * 匹配对象

    * "Match"

    * "expand()"

    * "group()"

    * "__getitem__()"

    * "groups()"

    * "groupdict()"

    * "start()"

    * "end()"

    * "span()"

    * "pos"

    * "endpos"

    * "lastindex"

    * "lastgroup"

    * "re"

    * "string"

  * 正则表达式例子

    * 检查对子

    * 模拟 scanf()

    * search() vs. match()

    * 制作一个电话本

    * 文字整理

    * 查找所有副词

    * 查找所有的副词及其位置

    * 原始字符串标记

    * 写一个词法分析器

* "difflib" --- 计算差异的辅助工具

  * "Differ"

  * "HtmlDiff"

    * "__init__()"

    * "make_file()"

    * "make_table()"

  * "context_diff()"

  * "get_close_matches()"

  * "ndiff()"

  * "restore()"

  * "unified_diff()"

  * "diff_bytes()"

  * "IS_LINE_JUNK()"

  * "IS_CHARACTER_JUNK()"

  * SequenceMatcher 对象

    * "SequenceMatcher"

      * "set_seqs()"

      * "set_seq1()"

      * "set_seq2()"

      * "find_longest_match()"

      * "get_matching_blocks()"

      * "get_opcodes()"

      * "get_grouped_opcodes()"

      * "ratio()"

      * "quick_ratio()"

      * "real_quick_ratio()"

  * SequenceMatcher 的示例

  * Differ 对象

    * "compare()"

  * Differ 示例

  * difflib 的命令行接口

  * ndiff 示例

* "textwrap" --- 文本自动换行与填充

  * "wrap()"

  * "fill()"

  * "shorten()"

  * "dedent()"

  * "indent()"

  * "TextWrapper"

    * "width"

    * "expand_tabs"

    * "tabsize"

    * "replace_whitespace"

    * "drop_whitespace"

    * "initial_indent"

    * "subsequent_indent"

    * "fix_sentence_endings"

    * "break_long_words"

    * "break_on_hyphens"

    * "max_lines"

    * "placeholder"

    * "wrap()"

    * "fill()"

* "unicodedata" --- Unicode 数据库

  * "lookup()"

  * "name()"

  * "decimal()"

  * "digit()"

  * "numeric()"

  * "category()"

  * "bidirectional()"

  * "combining()"

  * "east_asian_width()"

  * "mirrored()"

  * "decomposition()"

  * "normalize()"

  * "is_normalized()"

  * "unidata_version"

  * "ucd_3_2_0"

* "stringprep" --- 因特网字符串预处理

  * "in_table_a1()"

  * "in_table_b1()"

  * "map_table_b2()"

  * "map_table_b3()"

  * "in_table_c11()"

  * "in_table_c12()"

  * "in_table_c11_c12()"

  * "in_table_c21()"

  * "in_table_c22()"

  * "in_table_c21_c22()"

  * "in_table_c3()"

  * "in_table_c4()"

  * "in_table_c5()"

  * "in_table_c6()"

  * "in_table_c7()"

  * "in_table_c8()"

  * "in_table_c9()"

  * "in_table_d1()"

  * "in_table_d2()"

* "readline" --- GNU readline 接口

  * "backend"

  * 初始化文件

    * "parse_and_bind()"

    * "read_init_file()"

  * 行缓冲区

    * "get_line_buffer()"

    * "insert_text()"

    * "redisplay()"

  * 历史文件

    * "read_history_file()"

    * "write_history_file()"

    * "append_history_file()"

    * "get_history_length()"

    * "set_history_length()"

  * 历史列表

    * "clear_history()"

    * "get_current_history_length()"

    * "get_history_item()"

    * "remove_history_item()"

    * "replace_history_item()"

    * "add_history()"

    * "set_auto_history()"

  * 启动钩子

    * "set_startup_hook()"

    * "set_pre_input_hook()"

  * Completion

    * "set_completer()"

    * "get_completer()"

    * "get_completion_type()"

    * "get_begidx()"

    * "get_endidx()"

    * "set_completer_delims()"

    * "get_completer_delims()"

    * "set_completion_display_matches_hook()"

  * 示例

* "rlcompleter" --- 用于 GNU readline 的补全函数

  * "Completer"

    * "complete()"
