How to replace unicode characters in string with something else python?

后端 未结 4 666
暗喜
暗喜 2020-11-29 02:51

I have a string that I got from reading a HTML webpage with bullets that have a symbol like \"•\" because of the bulleted list. Note that the text is an HTML source from a w

4条回答
  •  孤城傲影
    2020-11-29 03:31

    Encode string as unicode.

    >>> special = u"\u2022"
    >>> abc = u'ABC•def'
    >>> abc.replace(special,'X')
    u'ABCXdef'
    

提交回复
热议问题