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.
string— Common string operationsre— Regular expression operationsdifflib— Helpers for computing deltasDifferHtmlDiffcontext_diff()get_close_matches()ndiff()restore()unified_diff()diff_bytes()IS_LINE_JUNK()IS_CHARACTER_JUNK()- 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()
- SequenceMatcher Examples
- Differ Objects
- Differ Example
- A command-line interface to difflib
- ndiff example
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()
unicodedata— Unicode Databasestringprep— Internet String Preparationreadline— GNU readline interfacerlcompleter— Completion function for GNU readline