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

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

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

问题

Here's the translated code:

  1. @commands.command()
  2. async def test(self, ctx, text):
  3. if """" in text:
  4. await ctx.send("bad")
  5. if text == "ok":
  6. await ctx.send("ok")
  7. else:
  8. await ctx.send("no")

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

英文:
  1. @commands.command()
  2. async def test(self, ctx, text):
  3. if "\"" in text:
  4. await ctx.send("bad")
  5. if text == "ok":
  6. await ctx.send("ok")
  7. else:
  8. 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

只需像这样检查:

  1. if ''"'' in text:

引用在' '中的"

英文:

just make the check like this

  1. 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:

确定