【问题标题】:Can particular word be detected even if there are some letters in front or back of a word? (PYTHON)即使单词前面或后面有一些字母,是否可以检测到特定单词? (PYTHON)
【发布时间】:2019-02-11 09:08:25
【问题描述】:
bot = commands.Bot(command_prefix='#')

@bot.event
async def on_message(message):
    if message.content == "detect":
        await bot.send_message(message.channel, "detected")

这是我通过 python 制作 discord bot 的代码(已跳过),我想检测“检测”这个词 我成功地检测到了那个词,但它无法检测到其他字母什么时候在那个词的前面或后面。 (例如一些检测到的东西)

即使有一些其他字母,是否有任何解决方案来检测“检测”这个词?

【问题讨论】:

  • 你试过了吗:如果message.content中的“检测”:
  • 请注意,"detect" in "undetectable"True,这可能是也可能不是您想要的,尤其是当您提到“单词”时。

标签: python bots discord


【解决方案1】:

我认为这应该可行:

bot = commands.Bot(command_prefix='#')

@bot.event
async def on_message(message):
    if "detect" in message.content:
        await bot.send_message(message.channel, "detected")

【讨论】:

    猜你喜欢
    • 2022-01-22
    • 1970-01-01
    • 1970-01-01
    • 2010-12-22
    • 1970-01-01
    • 2020-05-29
    • 2013-08-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多