Methods of String Objects
Plain and Unicode strings are immutable sequences, as covered in Strings. All immutable-sequence operations (repetition, concatenation, indexing, slicing) apply to strings. A string object s
also supplies several nonmutating methods, as documented in this section. Unless otherwise noted, each method returns a plain string when s
is a plain string, or a Unicode string when s
is a Unicode string. Terms such as “letters,” “whitespace,” and so on, refer to the corresponding attributes of the string
module, covered in The string Module. See also Locale Sensitivity.
capitalize |
Returns a copy of |
center |
Returns a string of length |
count |
Returns the number of nonoverlapping occurrences of substring |
encode |
Returns a plain string obtained from |
endswith |
Returns |
expandtabs |
Returns a copy of |
Get Python in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.