Remove all hex characters from string in Python

后端 未结 4 1120
失恋的感觉
失恋的感觉 2021-02-04 11:18

Although there are similar questions, I can\'t seem to find a working solution for my case:

I\'m encountering some annoying hex chars in strings, e.g.

\'         


        
4条回答
  •  灰色年华
    2021-02-04 12:00

    You can use decode after encoding just like this

    s.encode('ascii', errors='ignore').decode("utf-8")
    

提交回复
热议问题