How to fix broken utf-8 encoding in Python?

前端 未结 3 1966
感动是毒
感动是毒 2021-02-08 13:48

My string is Niệm Bồ Tát (Thiá»n sư Nhất Hạnh) and I want to decode it to Niệm Bồ Tát (Thiền sư Nhất Hạnh). I see in that site can do that ht

3条回答
  •  萌比男神i
    2021-02-08 14:35

    Try:

    str.encode('ascii', 'ignore').decode('utf-8')

    You're encoding the string in ASCII format / ignoring the errors and decoding in UTF-8. This may remove the accents, but it's one approach.

提交回复
热议问题