How do I case fold a string in Python 2?

后端 未结 3 1010
情话喂你
情话喂你 2020-12-16 01:00

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?

3条回答
  •  星月不相逢
    2020-12-16 01:32

    Check out py2casefold.

    >>> from py2casefold import casefold
    >>> print casefold(u"tschüß")
    tschüss
    >>> casefold(u"ΣίσυφοςfiÆ") == casefold(u"ΣΊΣΥΦΟσFIæ") == u"σίσυφοσfiæ"
    True
    

提交回复
热议问题