Search code examples
pythonunicodesymbolsemoji

In Python, how to convert from symbols to emojis?


I have a list of black symbols that I want to show as an emoji. How do I convert from a black symbol to the colorful emoji?

enter image description here

I was using import emoji but that library also uses the black symbols.

print('☀')
print('☀️')

Solution

  • Depending on the compatibility of your browser/terminal/IDE, a variation selector (U+FE0F) can be used to convert:

    >>> print('\u2600')
    ☀
    >>> print('\u2600\ufe0f')
    ☀️
    >>> print('\u2708')
    ✈
    >>> print('\u2708\ufe0f')
    ✈️