I'm a newbie in python. And apologies for a very basic question.
I'm working with python pattern.en
library and try to get the synonyms of a word. this is my code and is working fine.
from pattern.en import wordnet
a=wordnet.synsets('human')
print a[0].synonyms
this what the output i get from this:
[u'homo', u'man', u'human being', u'human']
but for my program i need to insert this array as this:
['homo', 'man', 'human being', 'human']
how do i get an output as above and remove the 'u' from my output.
thanks in advance..!
Try proper encoding- But care this u
does not have any effect on data- it is just an explicit representation of unicode object (not byte array), if your code needs back unicode
then better to feed it unicode.
>>>d = [u'homo', u'man', u'human being', u'human']
>>>print [i.encode('utf-8') for i in d]
>>>['homo', 'man', 'human being', 'human']