Python - lower() vs. casefold() for string matching and converting to lowercase
Python tip:
Use
.casfolde()
instead of.lower()
when you want to perform caseless operations when working with Unicode strings (for ASCII only strings they work the same) -- e.g., check if two strings are equal.# In German ß == ss print("straße".lower() == "strasse") # False print("straße".casefold() == "strasse") # True