6. Text Processing Services¶
The modules described in this chapter provide a wide range of string manipulation operations and other text processing services.
The codecs module described under Binary Data Services is also
highly relevant to text processing. In addition, see the documentation for
Python’s built-in string type in Text Sequence Type — str.
- 6.1.
string— Common string operations - 6.2.
re— Regular expression operations - 6.3.
difflib— Helpers for computing deltasSequenceMatcherDifferHtmlDiffcontext_diff()get_close_matches()ndiff()restore()unified_diff()diff_bytes()IS_LINE_JUNK()IS_CHARACTER_JUNK()- 6.3.1. SequenceMatcher Objects
SequenceMatcherSequenceMatcher.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()
- 6.3.2. SequenceMatcher Examples
- 6.3.3. Differ Objects
- 6.3.4. Differ Example
- 6.3.5. A command-line interface to difflib
- 6.4.
textwrap— Text wrapping and fillingwrap()fill()shorten()dedent()indent()TextWrapperTextWrapper.widthTextWrapper.expand_tabsTextWrapper.tabsizeTextWrapper.replace_whitespaceTextWrapper.drop_whitespaceTextWrapper.initial_indentTextWrapper.subsequent_indentTextWrapper.fix_sentence_endingsTextWrapper.break_long_wordsTextWrapper.break_on_hyphensTextWrapper.max_linesTextWrapper.placeholderTextWrapper.wrap()TextWrapper.fill()
- 6.5.
unicodedata— Unicode Database - 6.6.
stringprep— Internet String Preparation - 6.7.
readline— GNU readline interface - 6.8.
rlcompleter— Completion function for GNU readline
