遍历if语句

时间:2020-04-06 13:15:49

标签: python if-statement iteration discord.py

我制作了一个自动为我验证用户身份的机器人

转到我的自动购买API网址,然后获取response

这是我的代码

if response['productId'] == "b936596e-8cdf-4090-78b7-08d7a3ec0911":
   await message.author.add_roles(onetap)

elif response['productId'] == "d66e3b18-4b14-4396-d9a6-08d7cb20b1e4":
    await message.author.add_roles(otc)

elif response['productId'] == "69f4b63b-b0cd-4ef1-7872-08d7a3ec0911":
    await message.author.add_roles(aimware)

elif response['productId'] == "f1c36a82-d8dd-422d-135b-08d7ca2ec9fd":
    await message.author.add_roles(personal)

await message.author.send('Your key has been validated. {0.author.mention}, please look at the #read-this channel to see how to download your config.'.format(message))
await message.author.remove_roles(auth)
await message.delete()

这里的问题是,当第一个if语句为true时,productID = f1c36a82-d8dd-422d-135b-08d7ca2ec9fd时,一切都会按我的意愿进行。但是,如果不是这种情况,并且productID是第二,第三或第四个字符串,则什么也不会发生。我没有收到任何错误,但该程序没有执行我想要的操作

0 个答案:

没有答案
相关问题