= Python String Methods = These methods are defined for all instances of the built-in [[Python/Builtins/Types#Str|str]] type. <> ---- == Capitalize == `str.capitalize()` ---- == CaseFold == The '''`casefold`''' method casefolds the string to lowercase letters. Non-ASCII characters may be irreversibly replaced with ASCII 'equivalents'. {{{ orig = ['ß', 'á', 'Á'] [o.casefold() for o in orig] # ['ss', 'á', 'á'] }}} ---- == Center == `str.center(width[, fillchar])` ---- == Count == `str.count(sub[, start[, end]])` ---- == Encode == `str.encode(encoding='utf-8', errors='strict')` ---- == EndsWith == `str.endswith(suffix[, start[, end]])` ---- == ExpandTabs == `str.expandtabs(tabsize=8)` ---- == Find == `str.find(sub[, start[, end]])` ---- == Format == `str.format(*args, **kwargs)` ---- == Format_Map == `str.format_map(mapping)` ---- == Index == `str.index(sub[, start[, end]])` ---- == IsAlnum == `str.isalnum()` ---- == IsAlpha == `str.isalpha()` ---- == IsASCII == `str.isascii()` ---- == IsDecimal == `str.isdecimal()` ---- == IsDigit == `str.isdigit()` ---- == IsIdentifier == `str.isidentifier()` ---- == IsLower == `str.islower()` ---- == IsNumeric == `str.isnumeric()` ---- == IsPrintable == `str.isprintable()` ---- == IsSpace == `str.isspace()` ---- == IsTitle == `str.istitle()` ---- == IsUpper == `str.isupper()` ---- == Join == `str.join(iterable)` ---- == LJust == `str.ljust(width[, fillchar])` ---- == Lower == The '''`lower`''' method casefolds the string to lowercase letters. Unlike the `casefold` and `upper` methods, non-ASCII characters are preserved losslessly. {{{ orig = ['ß', 'á', 'Á'] [o.lower() for o in orig] # ['ß', 'á', 'á'] }}} ---- == LStrip == `str.lstrip([chars])` ---- == MakeTrans == `str.maketrans(x[, y[, z]])` ---- == Partition == `str.partition(sep)` ---- == RemovePrefix == `str.removeprefix(prefix, /)` ---- == RemoveSuffix == `str.removesuffix(suffix, /)` ---- == Replace == `str.replace(old, new[, count])` ---- == RFind == `str.rfind(sub[, start[, end]])` ---- == RIndex == `str.rindex(sub[, start[, end]])` ---- == RJust == `str.rjust(width[, fillchar])` ---- == RPartition == `str.rpartition(sep)` ---- == RStrip == `str.rstrip([chars])` ---- == Split == `str.split(sep=None, maxsplit=-1)` ---- == SplitLines == `str.splitlines(keepends=False)` ---- == StartsWith == `str.startswith(prefix[, start[, end]])` ---- == Strip == `str.strip([chars])` ---- == SwapCase == `str.swapcase()` ---- == Title == `str.title()` ---- == Translate == `str.translate(table)` ---- == Upper == The '''`upper`''' method casefolds the string to uppercase letters. Non-ASCII characters may be irreversibly replaced with ASCII 'equivalents'. {{{ orig = ['ß', 'á', 'Á'] [o.upper() for o in orig] # ['SS', 'Á', 'Á'] }}} ---- == ZFill == `str.zfill(width)` ---- CategoryRicottone