How do I case fold a string in Python 2?
问题 Python 3.3 adds the casefold method to the str type, but in 2.x I don't have anything. What's the best way to work around this? 回答1: Check out py2casefold. >>> from py2casefold import casefold >>> print casefold(u"tschüß") tschüss >>> casefold(u"ΣίσυφοςfiÆ") == casefold(u"ΣΊΣΥΦΟσFIæ") == u"σίσυφοσfiæ" True 回答2: There is a thread here which covers some of the issues (but may not resolve all), you can judge whether it is suitable for what you need. If this is no good then there are some useful