geekpradd / PyDictionary

PyDictionary is a Dictionary Module for Python 2/3 to get meanings, translations, synonyms and antonyms of words
https://pypi.python.org/pypi/PyDictionary
MIT License
274 stars 65 forks source link

How to remove the 'u' before each result? #13

Open Elliot-Potts opened 7 years ago

Elliot-Potts commented 7 years ago

Hello. Sorry for my ignorance here. I was just wondering how I'd remove the 'u' before each result. I am trying to get the synonym for (Example) word 'Hello', and then use PyTTSX to read it back to them, however I am unsure on how to remove the 'u' at the beginning of each word/synonym.

Any help would be greatly appreciated. Thanks.

modelmat commented 6 years ago

@Elliot-Potts The u is for unicode text in python. You can use str.encode("utf-8") to turn it into a normal string.

b1tninja commented 3 years ago

hey @Elliot-Potts, I recently used this library in conjunction with pyttsx3 to read out definitions. Maybe you would find it interesting. https://github.com/b1tninja/misty/blob/main/definitions.py as for the u prefix, I believe that if you switched to python3 you wouldn't "see" the u. The strings in in python2 that were unicode showed with a u prefix when you used print(). perhaps text.decode('utf-8') as @Modelmat suggested