top of page

How to Print Emoji in Python

Everything in memory is stored in binary format. The same way emojis are. But it is difficult to identify the emojis in binary format. Every Emojis have pre-defined encoded Unicode Character.


Python have multiple ways which is used to print the emojis. They are:

  1. Unicode

  2. CLDR Names

  3. Emojis Module


Unicode:

Unicode provides unique number for every character and symbols in every language in the world.


Syntax:

print("\emojis-unicode")

Below are some of the unicode of emojis:


U+1F600


U+1F923


U+1F970


U+1F618


U+1F917




Code:

# grinning face
print("\U0001f600" "-Grinning Face")
  
# Hugging Face
print("\U0001F917""-Hugging Face")
  
# rolling on the floor laughing
print("\U0001F923""-Rolling on the floor laughing")


Output:





CLDR Names:

It Collects short character names and keywords for Emoji characters and sequences.


Syntax:

print("\N{CLDR name of emoji}")

Below are some of the CLDR names for the above emojis:

  1. Grinning Face

  2. Rolling on the floor laughing

  3. Smiling face with hearts

  4. face blowing a kiss

  5. Hugging face

  6. and so on....


Code:

# grinning face
print("\N{grinning face}""-Grinning Face")
  
# slightly smiling face
print("\N{slightly smiling face}""-Slightly Smiling Face")
  
# winking face
print("\N{winking face}""-Winking Face")

Output:




Emojis Module:

Emojis can also be implemented by using the emoji module provided in Python. To install it run the following in the terminal.

pip install emoji

emojize() function requires the CLDR short name to be passed in it as the parameter. It then returns the corresponding emoji. Replace the spaces with underscore in the CLDR short name.


Code:

# import emoji module 
import emoji
   
print(emoji.emojize(":grinning_face_with_big_eyes:"))
print(emoji.emojize(":winking_face_with_tongue:"))
print(emoji.emojize(":zipper-mouth_face:"))


Output:










The Tech Platform

0 comments

Comentarios


bottom of page