Python: Comparing strings with accented characters does not work

后端 未结 2 1452
庸人自扰
庸人自扰 2021-01-07 05:27

I\'m quite new to python. I am trying to remove files that appear on one list from another list. The lists were produced by redirecting ll -R on mac and on windows (but have

2条回答
  •  盖世英雄少女心
    2021-01-07 05:32

    Use unicodedata.normalize to normalize the to strings to the same normal form:

    import unicodedata
    
    encoded1 = unicodedata.normalize('NFC', word1.decode('utf8'))
    encoded2 = unicodedata.normalize('NFC', word2.decode('utf8'))
    

提交回复
热议问题