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

前端 未结 10 2853
夕颜
夕颜 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 01:57

    Here is an example code

    import unicodedata    
    raw_text = u"here $%6757 dfgdfg"
    convert_text = unicodedata.normalize('NFKD', raw_text).encode('ascii','ignore')
    

提交回复
热议问题