Skip to content

Instantly share code, notes, and snippets.

@pbcquoc
Forked from jezdez/is_emoji.py
Created October 12, 2017 09:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pbcquoc/c169e37cf4bf85780354a66591098465 to your computer and use it in GitHub Desktop.
Save pbcquoc/c169e37cf4bf85780354a66591098465 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'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment