如何将表情符号与字符串联系起来

How to contact emoji with string

我在将 these Unicode emojis 与 Python3 中的字符串连接时遇到问题(以发送 Pushwoosh 通知)。

我将表情符号定义为 Unicode 变量:

stick_out_tongue = u'U+1F61C'

然后像这样连接字符串:

message = ' Message here...'
message = stick_out_tongue + message

但输出看起来像:

'U+1F61C Message here...'

请帮助。

正如@lenz 所说,您可能正在寻找“\U0001f61c”。那是一个特定的unicode字符代码。当您编写 "u'U+1F61C'" 时,它只需要文本 "U+1F61C" 并将其编码为 un​​icode 字符。您可以使用“\U”指定一个 unicode 字符代码(与 unicode 文本相对)。有关详细信息,请参阅 this tutorial