Skip to content

Instantly share code, notes, and snippets.

@jezdez
Created December 7, 2015 19:36
Show Gist options
  • Save jezdez/0185e35704dbdf3c880f to your computer and use it in GitHub Desktop.
Save jezdez/0185e35704dbdf3c880f to your computer and use it in GitHub Desktop.
A Python script to check if a character is or a text contains emoji
# -*- encoding: utf-8 -*-
# pip install emoji
import emoji
def char_is_emoji(character):
return character in emoji.UNICODE_EMOJI
def text_has_emoji(text):
for character in text:
if character in emoji.UNICODE_EMOJI:
return True
return False
if __name__ == '__main__':
print(char_is_emoji(u'\u2764'))
print(text_has_emoji(u'I \u2764 emoji'))
@danner26
Copy link

@claram97 thank you, EMOJI_DATA is the proper replacement for UNICODE_EMOJI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment