为什么python if命令不能正常工作


@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

我对if命令有问题。你可以在这里看到打印(id(和打印(不一致(代码的结果:

806114153915875378
806114153915875378

你可以看到不和谐和本我是一样的。但是

if discordid == id:
await ctx.send("worked")

代码无法正常工作,机器人程序无法发送消息。终端上没有打印错误。

试试这个程序

if str(discordid) == str(id):
await ctx.send("worked")

最新更新