- emoji 2.7.0
- Example
- Installation
- Developing
- Links
- How to Include Emojis in Your Python Code
- Print Emojis Using Python
- Using Unicode Characters to Print Emoji
- Using CLDR Short Names to Print Emoji
- Using the Emoji Library to Print Emoji
- Python program to print Emojis
- Python3
- Python3
- Python3
- Python Emoji Module: A Complete Guide
- Emojis in Modern Communication
- Using the Emoji Module to Print Emojis
- Understanding Unicode for Emojis
- FAQs
- What are unicodes?
- Where can I find the Emoji Cheat Sheet?
- Conclusion
emoji 2.7.0
Emoji for Python. This project was inspired by kyokomi.
Example
The entire set of Emoji codes as defined by the Unicode consortium is supported in addition to a bunch of aliases. By default, only the official list is enabled but doing emoji.emojize(language=’alias’) enables both the full list and aliases.
By default, the language is English ( language='en' ) but also supported languages are:
- Spanish ( ‘es’ )
- Portuguese ( ‘pt’ )
- Italian ( ‘it’ )
- French ( ‘fr’ )
- German ( ‘de’ )
- Farsi/Persian ( ‘fa’ )
- Indonesian ( ‘id’ )
- Simplified Chinese ( ‘zh’ )
- Japanese ( ‘ja’ )
- Korean ( ‘ko’ )
Installation
python -m pip install emoji --upgrade
git clone https://github.com/carpedm20/emoji.git emoji python -m pip install .
Developing
git clone https://github.com/carpedm20/emoji.git emoji python -m pip install -e . pytest coverage run -m pytest coverage report
The utils/get_codes_from_unicode_emoji_data_files.py is used to generate unicode_codes/data_dict.py . Generally speaking it scrapes a table on the Unicode Consortium’s website with BeautifulSoup and prints the contents to stdout as a Python dictionary. For more information take a look in the utils/README.md file.
Links
Documentation
Overview of all emoji:
(auto-generated list of the emoji that are supported by the current version of this package)
For English:
For Spanish:
For Portuguese:
For Italian:
How to Include Emojis in Your Python Code
Want to make your Python code fun for collaborators? Learn how to include emojis in Python.
Readers like you help support MUO. When you make a purchase using links on our site, we may earn an affiliate commission. Read More.
An emoji is a small digital image used to express an idea or emotion. Integrating emojis with programming can be fun. It makes programming an enjoyable task. You can use emojis in comments, commit messages or directly in code. You can convert boring texts like production logs and documentation into interesting text by using emojis. Even people tend to pick lines having emojis which increases productivity.
Since Python is known for its versatility, you can perform many operations on emoji using Python.
Print Emojis Using Python
Printing emojis using Python seems to be difficult but it’s deceptively simple. You can use Unicode characters, CLDR names or Python library emoji to print emojis.
Using Unicode Characters to Print Emoji
Unicode is a universal character encoding standard that assigns a code to every character and symbol in every language in the world. Every emoji has a unique Unicode assigned to it. When using Unicode with Python, replace «+» with «000» from the Unicode. And then prefix the Unicode with «\».
For example- U+1F605 will be used as \U0001F605. Here, «+» is replaced with «000» and «\» is prefixed with the Unicode.
# grinning face
print("\U0001F600")
# beaming face with smiling eyes
print("\U0001F601")
# grinning face with sweat
print("\U0001F605")
# rolling on the floor laughing
print("\U0001F923")
# face with tears of joy
print("\U0001F602")
# slightly smiling face
print("\U0001F642")
# smiling face with halo
print("\U0001F607")
# smiling face with heart-eyes
print("\U0001F60D")
# zipper-mouth face
print("\U0001F910")
# unamused face
print("\U0001F612")
The above code will give the following output:
Using CLDR Short Names to Print Emoji
CLDR collects short character names and keywords for Emoji characters and sequences. This method is more comfortable and easy to use.
# smiling face with sunglasses
print("\N")
# grinning face
print("\N")
# loudly crying face
print("\N")
# rolling on the floor laughing
print("\N")
# face with tears of joy
print("\N")
# slightly smiling face
print("\N")
# smiling face with halo
print("\N")
# angry face
print("\N")
# zipper-mouth face
print("\N")
# unamused face
print("\N")
The above code will give the following output:
Using the Emoji Library to Print Emoji
This library makes it easy to integrate emojis with Python programs. But you need to install this library before using it. Make sure you have pip installed on your system. Run the following in the command prompt:
Python program to print Emojis
There are multiple ways we can print the Emojis in Python. Let’s see how to print Emojis with Unicodes, CLDR names and emoji module.
Using Unicodes:
Every emoji has a Unicode associated with it. Emojis also have a CLDR short name, which can also be used.
From the list of unicodes, replace “+” with “000”. For example – “U+1F600” will become “U0001F600” and prefix the unicode with “\” and print it.
Python3
Using CLDR short name:
Python3
Using emoji module:
Emojis can also be implemented by using the emoji module provided in Python. To install it run the following in the terminal.
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.
Python3
demojize() function converts the emoji passed into its corresponding CLDR short name.
Below is a list of some common emoji Unicodes with their CLDR short names:
CLDR Short Name | Unicode |
---|---|
grinning face | U+1F600 |
grinning face with big eyes | U+1F603 |
grinning face with smiling eyes | U+1F604 |
beaming face with smiling eyes | U+1F601 |
grinning squinting face | U+1F606 |
grinning face with sweat | U+1F605 |
rolling on the floor laughing | U+1F923 |
face with tears of joy | U+1F602 |
slightly smiling face | U+1F642 |
upside-down face | U+1F643 |
winking face | U+1F609 |
smiling face with smiling eyes | U+1F60A |
smiling face with halo | U+1F607 |
smiling face with 3 hearts | U+1F970 |
smiling face with heart-eyes | U+1F60D |
star-struck | U+1F929 |
face blowing a kiss | U+1F618 |
kissing face | U+1F617 |
smiling face | U+263A |
kissing face with closed eyes | U+1F61A |
kissing face with smiling eyes | U+1F619 |
face savoring food | U+1F60B |
face with tongue | U+1F61B |
winking face with tongue | U+1F61C |
zany face | U+1F92A |
squinting face with tongue | U+1F61D |
money-mouth face | U+1F911 |
hugging face | U+1F917 |
face with hand over mouth | U+1F92D |
shushing face | U+1F92B |
thinking face | U+1F914 |
zipper-mouth face | U+1F910 |
face with raised eyebrow | U+1F928 |
neutral face | U+1F610 |
expressionless face | U+1F611 |
face without mouth | U+1F636 |
smirking face | U+1F60F |
unamused face | U+1F612 |
face with rolling eyes | U+1F644 |
grimacing face | U+1F62C |
lying face | U+1F925 |
relieved face | U+1F60C |
pensive face | U+1F614 |
sleepy face | U+1F62A |
drooling face | U+1F924 |
sleeping face | U+1F634 |
face with medical mask | U+1F637 |
face with thermometer | U+1F912 |
face with head-bandage | U+1F915 |
nauseated face | U+1F922 |
Python Emoji Module: A Complete Guide
Hey, there fellow learner! Today we will be learning something fun! We will be taking a look at the emoji module in python.
Emojis in Modern Communication
In today’s world, people communicate their emotions through emojis rather than typing out long passages. Emojis have become a major part of our day-to-day communication with each other.
Today in this tutorial I will be teaching you how to print emojis on your own using simple code lines and the emoji the module of python.
Using the Emoji Module to Print Emojis
In Python, you can utilize the emoji module to print emojis in your code. To do this, import the emoji module and use the emojize() and demojize() functions to convert text to emojis and vice versa. You can also print emojis using their Unicode values.
Before using the emoji module, you need to install it using pip. Open your terminal or command prompt and type the pip command to install the emoji module:
Once the installation is complete, you can import the emoji module in your Python script.
If any error occurs while importing, we need to install the module using the pip command on the command prompt.
To print an emoji on the screen, we will be using the emojize() function, which takes the CLDR short name of the emoji enclosed within colons (e.g., ‘:emoji_name:’) as a parameter.
The function automatically returns the emoji as a result.
If for some reason you don’t know the text for a particular emoji, we can use the demojize() function and pass the emoji as a parameter.
Here’s a Python program to print emojis:
import emoji print(emoji.demojize('😃')) print(emoji.emojize("Hello there friend! :grinning_face_with_big_eyes:"))
The output of the code is shown below. You can see the first function converted emoji to text while the second function converted text to emoji.
:grinning_face_with_big_eyes: Hello there friend! 😃
Understanding Unicode for Emojis
Instead of using emoji names, we can directly use the Unicode value for an emoji. Every emoji has a unique Unicode value that can be used to represent it.
You can get the Unicode for any emoji from this website. All we need to do is replace the + in the Unicode with 000 to get the correct Unicode.
Printing emoji using Unicode is very simple which doesn’t require any function other than the print statement along with a backslash ( \ ) before the Unicode to print the emoji.
The code below displays printing a bunch of emojis together with the help of unicodes.
print("\U0001F680 \U0001F649 \U0001F698 \U0001F6C1")
The output of the code above is as follows:
FAQs
What are unicodes?
Unicodes are a standardized system of identifying and encoding characters from various writing systems around the world. Each character is assigned a unique number or code point, enabling computers and other devices to display and recognize them regardless of the language or script used. Unicodes include characters from languages such as Arabic, Chinese, Cyrillic, Greek, Hebrew, Hindi, Japanese, Korean, and Latin, among others. They are widely used in software development, web design, and other digital applications.
Where can I find the Emoji Cheat Sheet?
To find the appropriate text or Unicode representation for a specific emoji, you can use an emoji cheat sheet. Websites like Emojipedia or the Unicode Emoji List provide comprehensive lists of emojis and their corresponding text and Unicode values. This can be helpful when you need to find a specific emoji for your project.
Conclusion
In this tutorial, we explored how to use the Python emoji module to print emojis and their corresponding Unicode values. This versatile tool can enhance your text-based projects and add a touch of fun to your code. What creative ways can you think of to incorporate emojis into your Python projects?