How to use the emoji module in Python

Overview

An emoji is a pictogram, logogram, ideogram, or smiley embedded in the text and used in electronic messages and web pages. They can represent emotion, weather conditions, hand gestures, people, animals, objects, etc. They replace the conventional typographical style.

In Python, emojis can be printed using the emoji module provided in it.

Install the emoji module

To install the emoji module, run the following command in the terminal window.

pip install emoji

Syntax

emoji.emojize()

Parameter value

The emoji.emojize() function takes the parameter value as the CLDR short name.

Return value

The emoji.emojize() function returns the emoji corresponding to the CLDR short name passed into it as a paremerer.

Example

import emoji
# using the thumbs up CLDR short name
print(emoji.emojize('Python is really cool :thumbs_up:'))
# using the grinning face CLDR short name
print(emoji.emojize('Python is really cool :grinning_face:'))

Output

Python is really cool ๐Ÿ‘
Python is really cool ๐Ÿ˜€

Note: Every emoji has a CDLR short name associated with it.

New on Educative
Learn any Language for FREE all September ๐ŸŽ‰
For the entire month of September, get unlimited access to our entire catalog of beginner coding resources.
๐ŸŽ Gย iย vย eย aย wย aย y
30 Days of Code
Complete Educativeโ€™s daily coding challenge every day in September, and win exciting Prizes.

Free Resources