安装emoji
pip install emoji
生成emoji
>> import emoji
>> print(emoji.emojize('Python is :thumbs_up:'))
Python is 👍
>> print(emoji.emojize('Python is :thumbsup:', use_aliases=True))
Python is 👍
>> print(emoji.demojize('Python is 👍'))
Python is :thumbs_up:
>>> print(emoji.emojize("Python is fun :red_heart:"))
Python is fun ?
>>> print(emoji.emojize("Python is fun :red_heart:",variant="emoji_type"))
Python is fun ??
>>> print(emoji.is_emoji("👍"))
True
移除emoji
def deEmojify(text):
'''移除emoji表情'''
return emoji.get_emoji_regexp().sub(u'', text)
text = "今天天气真好😓😓😓呀🤔"
print(deEmojify(text))
参考链接: emoji的文档 emoji字符大全 removing-emojis-from-a-string-in-python
|