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 字符串的方法 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
— 常见的字符串操作 - 7.2.
re
— 正则表达式操作 - 7.3.
struct
— Interpret strings as packed binary data - 7.4.
difflib
— 计算差异的辅助工具 - 7.5.
StringIO
— Read and write strings as files - 7.6.
cStringIO
— Faster version ofStringIO
- 7.7.
textwrap
— 文本自动换行与填充 - 7.8.
codecs
— 编解码器注册和相关基类 - 7.9.
unicodedata
— Unicode 数据库 - 7.10.
stringprep
— 因特网字符串预备 - 7.11.
fpformat
— Floating point conversions