python - 在 python 中将表情符号 unicode 转换为文本

标签 python emoji

我有一个用 python (yowsup) 制作的应用程序,我在我的机器人中收到文本和表情符号... 我设法让 😀 转换为 "\U0001F600"代码...

现在我需要将 u"\U0001F600"转换为 :grinning: TEXT 或 GRINNING FACE

从这个页面得到了一些资源...... http://www.fileformat.info/info/unicode/char/1F600/index.htm

@signals.message_received.connect
def handle(message):
    #message.log() to see message object properties
    #print(message.log())
    params = {}
    params_upload = {}
    zapsend_host = config.config_variables['zapsend_host']
    zapsend_port = config.config_variables['zapsend_port']

    # CASE TEXT-MESSAGE AND NOT GROUP
    if helper.is_text_message(message.message_entity) and helper.isGroupJid(message.conversation) == False:
        #converted here....
        params['msg']  = message.text.encode('unicode_escape') 
        params['number']  = message.conversation
        params['whatsapp']= config.config_variables['user']
        params['media'] = 'text'
        params['caption'] = ''
        params['name'] = message.who_name
        database_helper.sync_contacts(message.conversation, message.who_name)
        database_helper.save_message_receive(params, message)
        print("MSG FROM CLIENT: "+ message.conversation +" => " + params['msg'])
        requests_helper.request_get(zapsend_host, zapsend_port,'zapsend',params)

最佳答案

@sealabr 检查这个。

import emoji
print(emoji.demojize('Python is 👍'))
>>Python is :thumbs_up:

关于python - 在 python 中将表情符号 unicode 转换为文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47489836/

相关文章:

ios - 带有表情符号设置 : cursorPosition is not correct 的 UITextView.text

python - 在 Ubuntu 18.04 上安装最新版本的 QGis

python - 重构嵌套字典 Python

python - 如何在 Python 中从 XML/SOAP 中提取数据

python - 如何使用 Flask 从 URL 获取命名参数?

ios - UITextView 表情符号字符限制计数不正确

javascript - 有没有办法检查JS中的字符串是否是单个表情符号?

python - Django - 如何按特定顺序对对象进行排序?

android - 我如何处理 Android 中 Emojipicker 和键盘之间的切换?

ios - 判断字符串中的字符是否是表情符号?