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 |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access