{"id":26057,"date":"2021-12-14T08:45:42","date_gmt":"2021-12-14T03:15:42","guid":{"rendered":"https:\/\/python-programs.com\/?p=26057"},"modified":"2021-12-14T08:45:42","modified_gmt":"2021-12-14T03:15:42","slug":"python-emoji-module-with-examples","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-emoji-module-with-examples\/","title":{"rendered":"Python Emoji Module with Examples"},"content":{"rendered":"

People nowadays communicate their emotions with emojis rather than extended lengths of text. Emojis have become an important part\u00a0of our everyday communication with one another.<\/p>\n

Emoji Module:<\/strong><\/p>\n

In Python, we may print the Emojis in a number of ways. They are:<\/p>\n

printing Emojis with Unicodes, CLDR names, and the emoji module.<\/p>\n

UsingUnicodes:<\/strong><\/h3>\n

Every emoji is assigned a Unicode code.<\/p>\n

Replace “+” with “000” in the list of Unicodes. For example, “U+1F600” will become “U0001F600,” with the Unicode prefixed by “\\” and printed.<\/p>\n

Emojis have a CLDR short name that can be utilized as well.<\/p>\n

# Print the grinning face emoji\r\nprint(\"\\U0001f600\")\r\n \r\n#  grinning squinting face emoji\r\nprint(\"\\U0001F606\")\r\nprint(\"\\U0001F649\")\r\n# Print the rolling on the floor laughing emoji\r\nprint(\"\\U0001F923\")\r\n<\/pre>\n

Output:<\/strong><\/p>\n

\ud83d\ude00\r\n\ud83d\ude06\r\n\ud83d\ude49\r\n\ud83e\udd23<\/pre>\n

Using CLDR short name:<\/h3>\n
# Print the grinning face emoji\r\nprint(\"\\N{grinning face}\")\r\n \r\n# Print the slightly smiling face emoji\r\nprint(\"\\N{slightly smiling face}\")\r\n \r\n# Print the winking face emoji\r\nprint(\"\\N{winking face}\")<\/pre>\n

Output:<\/strong><\/p>\n

\ud83d\ude00\r\n\ud83d\ude42\r\n\ud83d\ude09<\/pre>\n

Using emoji Module:<\/strong><\/h3>\n

Before starting, install the emoji <\/strong>Module as shown below:<\/p>\n

pip install emoji<\/pre>\n

Output:<\/strong><\/p>\n

Collecting emoji Downloading emoji-1.6.1.tar.gz (170 kB) \r\n|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 170 kB 15.6 MB\/s Building wheels for \r\ncollected packages: emoji Building wheel for emoji (setup.py) ... done \r\nCreated wheel for emoji: filename=emoji-1.6.1-py3-none-any.whl size=169314 \r\nsha256=5e835eb87674dd1171fd982e5e4c9490dce2d715db0e401221ff8e8902e4b4c1 Stored \r\nin directory: \/root\/.cache\/pip\/wheels\/ea\/5f\/d3\/03d313ddb3c2a1a427bb4690f1621eea\r\n60fe6f2a30cc95940f Successfully built emoji Installing collected packages: emoji\r\nSuccessfully installed emoji-1.6.1<\/pre>\n

emojize() Method:<\/strong><\/p>\n

The CLDR short name must be passed as a parameter to the emojize() method. The relevant emoji is then returned. In the CLDR short name, replace the spaces with underscores.<\/p>\n

The emojize() method takes as a parameter the name of the emoji enclosed in a colon (:).<\/p>\n

Example:<\/strong><\/p>\n

Approach:<\/strong><\/p>\n