pythonpython-2.7unicode

Remove zero width space unicode character from Python string


I have a string in Python like this:

u'\u200cHealth & Fitness'

How can i remove the

\u200c

part from the string ?


Solution

  • You can encode it into ascii and ignore errors:

    u'\u200cHealth & Fitness'.encode('ascii', 'ignore')
    

    Output:

    'Health & Fitness'