7. String Services¶
The modules described in this chapter provide a wide range of string manipulation operations.
In addition, Python’s built-in string classes support the sequence type
methods described in the Sequence Types — str, unicode, list, tuple, bytearray, buffer, xrange section, and also the
string-specific methods described in the String Methods section.
To output formatted strings use template strings or the % operator
described in the String Formatting Operations section. Also, see the
re module for string functions based on regular expressions.
- 7.1.
string— Common string operations - 7.2.
re— Regular expression operations - 7.3.
struct— Interpret strings as packed binary data - 7.4.
difflib— Helpers for computing deltasSequenceMatcherDifferHtmlDiffcontext_diff()get_close_matches()ndiff()restore()unified_diff()IS_LINE_JUNK()IS_CHARACTER_JUNK()- 7.4.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()
- 7.4.2. SequenceMatcher Examples
- 7.4.3. Differ Objects
- 7.4.4. Differ Example
- 7.4.5. A command-line interface to difflib
- 7.5.
StringIO— Read and write strings as files - 7.6.
cStringIO— Faster version ofStringIO - 7.7.
textwrap— Text wrapping and filling - 7.8.
codecs— Codec registry and base classesencode()decode()register()lookup()getencoder()getdecoder()getincrementalencoder()getincrementaldecoder()getreader()getwriter()register_error()lookup_error()strict_errors()replace_errors()ignore_errors()xmlcharrefreplace_errors()backslashreplace_errors()open()EncodedFile()iterencode()iterdecode()BOMBOM_BEBOM_LEBOM_UTF8BOM_UTF16BOM_UTF16_BEBOM_UTF16_LEBOM_UTF32BOM_UTF32_BEBOM_UTF32_LE- 7.8.1. Codec Base Classes
- 7.8.2. Encodings and Unicode
- 7.8.3. Standard Encodings
- 7.8.4. Python Specific Encodings
- 7.8.5.
encodings.idna— Internationalized Domain Names in Applications - 7.8.6.
encodings.utf_8_sig— UTF-8 codec with BOM signature
- 7.9.
unicodedata— Unicode Database - 7.10.
stringprep— Internet String Preparation - 7.11.
fpformat— Floating point conversions
