Search code examples
pythonstringweb-scrapingasciinon-ascii-characters

Removing some characters from a string


I have some strings like this in Python: ' سلام دوستان;\xa0\xa0ج\xa0۲ \xa0ص\xa0۳۸۸ مى شود راهی پیدا کرد\u200c' How I can remove all \xa0 and \u200* characters from the strings?


Solution

  • You can use the replace method , to replace those characters with empty string.

    original_string =  'سلام دوستان;\xa0\xa0ج\xa0۲ \xa0ص\xa0۳۸۸ مى شود راهی پیدا کرد\u200c'
    
    new_string = original_string.replace('\xa0','').replace('\u200','')