How to remove this \xa0 from a string in python?

后端 未结 5 1107
心在旅途
心在旅途 2020-12-15 09:07

I have the following string:

 word = u\'Buffalo,\\xa0IL\\xa060625\'

I don\'t want the \"\\xa0\" in there. How can I get rid of it? The st

5条回答
  •  粉色の甜心
    2020-12-15 09:27

    You can easily use unicodedata to get rid of all of \x... characters.

    from unicodedata import normalize
    normalize('NFKD', word)
    >>> 'Buffalo, IL 60625'
    

提交回复
热议问题