DEV Community

Cover image for EmojišŸ˜ŠšŸ¤£ In Python
Ankit Kumar
Ankit Kumar

Posted on

EmojišŸ˜ŠšŸ¤£ In Python

Emoji's language is the worldā€™s fastest-growing language and there are more than 3000 emojis. So Why not start using emoji in our python program. In this article, you will learn how to use emoji in python.

For using emoji in python we need to install an emoji library, so open your command prompt and run this command.

pip install emoji
Enter fullscreen mode Exit fullscreen mode

This Command will install the emoji library on your computer and now you are ready to use emoji in your python program.

This library uses an emoji cheat sheet to display emoji of that particular cheat._ Cheat Sheet

>>> import emoji
#This command will import emoji library in your program
>>> print(emoji.emojize('Give a :thumbs_up: to this article.'))
Give a šŸ‘ to this article.
>>> print(emoji.emojize('Give a :red_heart: to this article.'))
Give a ā¤ to this article.
Enter fullscreen mode Exit fullscreen mode

By default, you can only use few emojis from the cheat sheet but for using the complete list you need to add emoji.emojize(use_aliases=True) in your code, this is how we do that.

>>> import emoji

>>> print(emoji.emojize('Are you feeling :angry:', use_aliases=True))
Are you feeling šŸ˜ 
>>> print(emoji.emojize('Dont forget to wear your :mask:', use_aliases=True))
Dont forget to wear your šŸ˜·

Enter fullscreen mode Exit fullscreen mode

That's it for this article, this is my third article so share some feedback to improve in the comment section.

Top comments (2)

Collapse
 
moopet profile image
Ben Sinclair • Edited

So Why not start using emoji in our python program

Oh go on then, since you asked :)

  1. They're likely to be inaccessible or at best read out by screen readers in a long-winded format like, "man with medium-light skin tone smiling while holding beer one hundred" which is a pain to listen to every time.
  2. You can't necessarily paste the code into everyone's editor
  3. different cultures mean different things by different symbols
  4. Different operating systems will use different emoji (Apple's water pistol in place of Microsoft's handgun for example)
  5. They might be radically different depending on font
  6. If the font's small, they all look a bit like pacman anyway
  7. if you use them in variable names (which has become a bit of a "cool thing" in Javascript land) you literally have to copy-paste them each time because you're never going to guess what variation the original coder used.

I'm not a fan of emoji in general for these reasons (and others). In your example, I can only infer the "mask" one by context because to me it looks like a generic smiley, and the one that's defined as :red_heart: is... a white heart. And I'm not overrinding any fonts or anything clever like that. They're just not reliable for anything other than the most trivial case, and I'd steer clear of using them for any, shall we say, "professional" product because they might turn out to be unexpectedly inappropriate on some systems.

Collapse
 
ankitdevelops profile image
Ankit Kumar

thanks for pointing out the mistake I have not thought about that