Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
即使单词的前面或后面有一些字母,也能检测到特定的单词吗?(PYTHON)_Python_Bots_Discord - Fatal编程技术网

即使单词的前面或后面有一些字母,也能检测到特定的单词吗?(PYTHON)

即使单词的前面或后面有一些字母,也能检测到特定的单词吗?(PYTHON),python,bots,discord,Python,Bots,Discord,这是我用python制作discord机器人的代码(跳过),我想检测“detect”这个词 我成功地检测到了那个单词,但它无法检测出该单词的前面或后面是否有其他字母。 (例如,一些探测到的东西) 是否有任何解决方案可以检测“detect”一词,即使还有其他字母?我认为这应该可以: bot = commands.Bot(command_prefix='#') @bot.event async def on_message(message): if message.content == "

这是我用python制作discord机器人的代码(跳过),我想检测“detect”这个词 我成功地检测到了那个单词,但它无法检测出该单词的前面或后面是否有其他字母。 (例如,一些探测到的东西)


是否有任何解决方案可以检测“detect”一词,即使还有其他字母?

我认为这应该可以:

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

@bot.event
async def on_message(message):
    if message.content == "detect":
        await bot.send_message(message.channel, "detected")
您是否尝试过:if“detect”在消息中。内容:请注意,“undetectable”中的
“detect”是
True
,这可能是您想要的,也可能不是您想要的,特别是因为您提到了“word”。
bot = commands.Bot(command_prefix='#')

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