[Python] Find there is an emoji in a string in python3 [duplicate]

Discussão em 'Python' iniciado por Stack, Agosto 1, 2025.

  1. Stack

    Stack Membro Participativo

    I want to check that a string contains only one emoji, using Python 3. For example, there is a is_emoji function that checks that the string has only one emoji.

    def is_emoji(s):
    pass

    is_emoji("") #True
    is_emoji("◼️") #False


    I try to use regular expressions but emojis didn't have fixed length. For example:

    print(len("◼️".encode("utf-8"))) # 6
    print(len("".encode("utf-8"))) # 4

    Continue reading...

Compartilhe esta Página