Удаление символов unicode\u2026 в строке в python2.7
У меня есть строка в python2.7, как это,
This is some \u03c0 text that has to be cleaned\u2026! it\u0027s annoying!
Как мне преобразовать его в это,
This is some text that has to be cleaned! its annoying!
Ответ 1
Python 2.x
>>> s
'This is some \\u03c0 text that has to be cleaned\\u2026! it\\u0027s annoying!'
>>> print(s.decode('unicode_escape').encode('ascii','ignore'))
This is some text that has to be cleaned! it annoying!
Python 3.x
>>> s = 'This is some \u03c0 text that has to be cleaned\u2026! it\u0027s annoying!'
>>> s.encode('ascii', 'ignore')
b"This is some text that has to be cleaned! it annoying!"