我正在为一个学校项目写一个石头,纸和剪刀机器人。我总是在标题(TypeError: randint() takes 3 positional arguments but 4 were given
)中出现错误,我不知道为什么。我的密码在下面。
if userInput : 'rock'
choice = random.randint(1,2,3)
if choice == 1:
await client.send_message(message.channel, embed=RockEmbed)
elif choice == 2:
await client.send_message(message.channel, embed=PaperEmbed)
elif choice == 3:
await client.send_message(message.channel, embed=ScissorsEmbed)
if userInput : 'scissors'
choice2 = random.randint(1,2,3)
if choice2 == 1:
await client.send_message(message.channel, embed=RockEmbed)
elif choice2 == 2:
await client.send_message(message.channel, embed=PaperEmbed)
elif choice2 == 3:
await client.send_message(message.channel, embed=ScissorsEmbed)
if userInput : 'paper'
choice3 = random.randint(1,2,3)
if choice3 == 1:
await client.send_message(message.channel, embed=RockEmbed)
elif choice3 == 2:
await client.send_message(message.channel, embed=PaperEmbed)
elif choice3 == 3:
await client.send_message(message.channel, embed=ScissorsEmbed)
我说过random.randint(1,2,3)
,它显然是3个参数,而不是4个。我非常肯定我的语法是正确的,但不是100%。
发布于 2021-03-31 07:34:16
如果需要多个随机数,也可以使用numpy.random.randint(start,stop-1,number of randoms)
https://stackoverflow.com/questions/46808438
复制相似问题