【问题标题】:How to contact emoji with string如何用字符串联系表情符号
【发布时间】:2020-06-18 15:58:12
【问题描述】:

我无法在 Python3 中将 these Unicode emojis 与字符串连接起来(以发送 Pushwoosh 通知)。

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

stick_out_tongue = u'U+1F61C'

然后像这样连接字符串:

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

但输出看起来像:

'U+1F61C Message here...'

请帮忙

【问题讨论】:

  • 这只是一个带有'U'、'+'等的字符串。你可能在'\U0001f61c'之后。
  • 您遇到的错误是什么?
  • 我敢肯定这个问题之前已经被问过,不管怎样,但我现在找不到合适的副本。不过,This thread 是相关的。

标签: python-3.x unicode emoji


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2014-04-06
    • 2015-03-17
    • 1970-01-01
    • 2016-03-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-12
    相关资源
    最近更新 更多