String Methods
Return to Python Pocket Reference Table of Contents
In addition to the format() method described earlier, string method calls provide higher-level text processing tools beyond string expressions. Table 9 lists available string method calls; in this table, S is any string object (technically, a 3.X str). String methods that modify text always return a new string and never modify the object in-place (strings are immutable).
For more details on methods in the table, see the functional area description sections ahead, or run a help(str.method) interactively. Hint: this list can vary across Python releases; to see yours, try:
sorted(x for x in dir(str) if not x.startswith('__'))
See also the re module in The re Pattern-Matching Module for pattern-based equivalents to some string type methods.
Table 9. Python 3.X string method calls
S.casefold() (as of Python 3.3)
S.encode(encoding [, errors]])
S.endswith(suffix [, start [, end)
S.format_map(mapping) (as of Python 3.2)