Convert a Unicode string to a string in Python (containing extra symbols)

前端 未结 10 2663
夕颜
夕颜 2020-11-22 01:20

How do you convert a Unicode string (containing extra characters like £ $, etc.) into a Python string?

10条回答
  •  隐瞒了意图╮
    2020-11-22 02:09

    See unicodedata.normalize

    title = u"Klüft skräms inför på fédéral électoral große"
    import unicodedata
    unicodedata.normalize('NFKD', title).encode('ascii', 'ignore')
    'Kluft skrams infor pa federal electoral groe'
    

提交回复
热议问题