【问题标题】:Why I can't use emojis as input in Python?为什么我不能在 Python 中使用表情符号作为输入?
【发布时间】:2019-07-23 01:33:55
【问题描述】:

这是电报机器人的代码。当用户写“x”或发送“????”时,我希望机器人说“嗨”表情符号。当用户写 x 时它工作,但发送时没有任何反应????。

我使用pythoneverywhere.com 作为主机并在其控制台中运行我的代码。

# -*- coding:utf-8 -*-
#coding=UTF-8

from telegram.ext import Updater, Filters, MessageHandler
from telegram import ParseMode , InputTextMessageContent
from emoji import emojize

updater = Updater("928344838:AAGUaVBq2ZTfqM059MZ1WXRFELb3EaEUkZw")

def msg_filter(bot , update):
    words = ['x','????']

    if any (i in update.message.text for i in words):
        bot.send_message(chat_id = update.message.chat_id , text = "Hi")

updater.dispatcher.add_handler(MessageHandler(Filters.text, msg_filter))

updater.start_polling()

【问题讨论】:

  • 提供repr(update.message.text)repr(words)
  • 它不起作用。

标签: python input emoji


【解决方案1】:

我猜 pythoneverywhere 或电报正在使用不支持表情符号的编码显示文本。 Python unicode 字符串本身就支持表情符号,所以我认为这不是 Python 问题。

【讨论】:

    猜你喜欢
    • 2016-07-02
    • 2021-02-13
    • 1970-01-01
    • 2011-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多