Python Glossary Русский

Python 3.3+Strings (str)function

str.casefold

case

Aggressive lowercasing for caseless matching (e.g. ß → ss).

Syntax

s.casefold()

For ASCII and Cyrillic text casefold() and lower() return the same thing; the difference shows up only where one letter has several written forms, like German ß or Greek final sigma ς. Hence the rule: compare caselessly with casefold(), display with lower() — casefold may change the letters and the length of the string, and that transformation cannot be undone.

Examples

print('Straße'.casefold())  # → strasse
print('ß'.casefold() == 'ss')  # → True
print('HeLLo'.casefold())   # → hello

See also

Open in the full glossarydocs.python.orgReport an inaccuracy