python - Why python if command doesnt work correctly?
问题描述
@Bot.command()
async def kod(ctx,discordid):
objects = Code.manager(db)
code_list = list(objects.all())
i = 1
while i <= len(code_list):
usercode = objects.get(i)
usercode = usercode.__dict__
id = usercode.get('discord_id')
print(discordid)
print(id)
if discordid == id:
await ctx.send("worked")
i = i + 1
I have problem with if command.you can see the result of the print(id) and print(discordid) code here:
806114153915875378
806114153915875378
You can see that discordid and id are the same. But
if discordid == id:
await ctx.send("worked")
Code doesnt work correctly and bot doesnt send message.There isnt a error printed at terminal.
解决方案
试试这个程序
if str(discordid) == str(id):
await ctx.send("worked")
推荐阅读
- python - Django Forms保存数据的问题
- javascript - Ajax 将布尔值与 HTML 一起从服务器传递到具有 HTML 数据类型的客户端
- java - Java - 循环平均 rgb 值应该是破坏性的......但不是
- java - 多次引用方法时保留变量
- c - 宏for_each_process的内核模块编译错误
- angular - 我如何获得 FormBuilder angular 的值并将其与属性 NgStyle 一起使用
- javascript - 反应输入状态不使用设置状态的更新函数更新
- spring - 使用 Java 8 的 Spring 的 @Condtional 注释
- environment-variables - 控制器中的 Symfony 4 .env 变量
- c - 在 C 代码块中调用 GUROBI 时未定义的引用