I want to test if a Unicode word that passed to the function isn’t in the list, function do some manipulate on this word. something like this:
def my_function(word):
if not word in [u'تست']:
...
well it works perfect. but my list is more bigger than this and I saved its words to a separate file. now I’m trying to read this file lines as words but I don’t know how to append theme as Unicode like [u'تست']. I tried to use unicode() but even after that if condition can’t find words that are already in the file.
Open the file using
codecs.openinstead ofopen, then everything you read from the file will beunicodeinstead ofstr.