如何将表情符号替换为文本中的单词?

use*_*_12 4 python python-3.x

想象一下我有这样的文字?

text = "game is on  "
Run Code Online (Sandbox Code Playgroud)

如何将文本中的表情符号转换为单词?

这是我尝试过的,下面的代码将表情符号转换为单词,但如何将其替换为原始文本中的表情符号。我想不通。

import emot
[emot.emoji(i).get('mean').replace(':','').replace('_',' ').replace('-',' ') for i in text.split()]
Run Code Online (Sandbox Code Playgroud)

预期输出:

game is on fire fire
Run Code Online (Sandbox Code Playgroud)

我遇到过这两个python模块 EmojiEmot但我不知道如何成功地将表情符号转换为文本并在文本句子中替换它。

任何人都可以帮忙吗?

Bor*_*ris 5

emoji.demojize接受一个可选delimiters=(":", ":")参数。将其更改为("", "")

import emoji
text = "game is on  "
emoji.demojize(text, delimiters=("", ""))  # 'game is on fire fire'
Run Code Online (Sandbox Code Playgroud)