I have a web scraper that takes forum questions, splits them into individual words and writes it to the text file. The words are stored in a list of tuples. Each tuple contains
I tested that with python 2.7. replace
works as expected:
>>> u'used\u200b'.replace(u'\u200b', '*')
u'used*'
and so does strip:
>>> u'used\u200b'.strip(u'\u200b')
u'used'
Just remember that the arguments to those functions have to be Unicode literals. It should be u'\u200b'
, not '\u200b'
. Notice the u
in the beginning.
And actually, writing that character to a file works just fine.
>>> import codecs
>>> f = codecs.open('a.txt', encoding='utf-8', mode='w')
>>> f.write(u'used\u200bZero')
See resources: