如何检查输入中是否包含双引号。

huangapple go评论75阅读模式
英文:

python - discord.py how can I check if double quotes are in intput

问题

Here's the translated code:

@commands.command()
async def test(self, ctx, text):
    if """" in text:
        await ctx.send("bad")
    if text == "ok":
        await ctx.send("ok")
    else:
        await ctx.send("no")

Please note that I've replaced the HTML entity " with double quotes " in the translated code.

英文:
@commands.command()
async def test(self, ctx, text):
        if "\"" in text:
            await ctx.send("bad")
        if text == "ok":
            await ctx.send("ok")
        else:
            await ctx.send("no")

When member send !submit askdsk says no but if a double quote " is in input there is no output i tried to do if "\"" in text: but it didn't work. Any ideas?

答案1

得分: 1

只需像这样检查:

if ''"'' in text:

引用在' '中的"

英文:

just make the check like this

if '"' in text:

quote the " in ' '

huangapple
  • 本文由 发表于 2023年5月6日 21:50:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/76189242.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定