Emoji for Python

2.15.0 ยท active ยท verified Sun Mar 29

The `emoji` library provides comprehensive support for handling Unicode emojis in Python, allowing conversion between emoji characters and their shortcodes (e.g., ๐Ÿ‘ to :thumbs_up:). It supports the entire set of Emoji codes defined by the Unicode consortium and various languages. The library is actively maintained, with version 2.15.0 being the latest, and typically releases updates to keep up with Unicode emoji standards.

Warnings

Install

Imports

Quickstart

The quickstart demonstrates the primary functions: `emojize` for converting text shortcodes to Unicode emojis, `demojize` for converting Unicode emojis back to shortcodes, `analyze` for extracting emoji information, and `replace_emoji` for substituting emojis with other strings.

import emoji

# Convert shortcodes to emoji
emojified_text = emoji.emojize('Python is fun :red_heart: :snake:')
print(f"Emojified: {emojified_text}")

# Convert emoji to shortcodes
demojified_text = emoji.demojize('Python is fun โค๏ธ๐Ÿ')
print(f"Demojified: {demojified_text}")

# Analyze text for emojis
emojis_found = list(emoji.analyze('Hello ๐Ÿ‘‹ world ๐ŸŒ'))
print(f"Emojis found: {emojis_found}")

# Replace emojis with a custom string
text_without_emojis = emoji.replace_emoji('Hello ๐Ÿ‘‹ world ๐ŸŒ', replace='[emoji]')
print(f"Text without emojis: {text_without_emojis}")

view raw JSON โ†’