Python 有人能帮我开货币店吗?
我对python有点陌生,但我知道一些基本的东西,比如变量和字符串,我最近创建了一个带有货币和商店的discord机器人。商店不工作,它的目的是让我为列出的物品买票(它不是为了存储任何东西)。你能帮我找出哪里出了问题并帮助我改进,或者告诉我哪里出了问题,在哪里我可以找到我的答案。以下是我在商店得到的信息(注意,我使用的是python 3.6.4): 如果您想在bot上查看我的完整代码,请单击此处:Python 有人能帮我开货币店吗?,python,python-3.x,bots,Python,Python 3.x,Bots,我对python有点陌生,但我知道一些基本的东西,比如变量和字符串,我最近创建了一个带有货币和商店的discord机器人。商店不工作,它的目的是让我为列出的物品买票(它不是为了存储任何东西)。你能帮我找出哪里出了问题并帮助我改进,或者告诉我哪里出了问题,在哪里我可以找到我的答案。以下是我在商店得到的信息(注意,我使用的是python 3.6.4): 如果您想在bot上查看我的完整代码,请单击此处: 您不应该需要while True:,因为这将进入一个无限循环,因为您没有break语句 将所有p
while True:
,因为这将进入一个无限循环,因为您没有break
语句李>
print()
语句替换为wait client.say()
语句@client.command(pass_context = True)
async def buy(ctx, item):
items = {
"Apex Legends": [3, 20],
"Minecraft": [5, 30],
"Halo": [5, 20],
"Fortnite": [8, 10],
}
await client.say("Apex Legends = 3BP / Minecraft = 5BP / Halo = 5BP / Fortnite = 8BP")
await client.say("Account Balance bp", stash)
choice = input("What would you like to buy?: ").strip().title()
if choice in items:
if items[choice][1]>0:
if stash>=items[choice][0]:
items[choice][1]=items[choice][1]-1
stash= stash-items[choice][0]
await client.say("Thank you..!")
await client.say("")
else:
await client.say("Sorry you dont enough money...")
await client.say("")
else:
await client.say("sorry sold out")
await client.say("")
else:
await client.say("Sorry we don't have that item...")
await client.say("")
您的代码中的具体错误或意外响应是什么?当我启动bot时,我的其他命令都不起作用,当我查看控制台时,它显示了我可以显示的内容,但在discord上,我希望它显示在discord上,而不是控制台上
@client.command(pass_context = True)
async def buy(ctx, item):
items = {
"Apex Legends": [3, 20],
"Minecraft": [5, 30],
"Halo": [5, 20],
"Fortnite": [8, 10],
}
await client.say("Apex Legends = 3BP / Minecraft = 5BP / Halo = 5BP / Fortnite = 8BP")
await client.say("Account Balance bp", stash)
choice = input("What would you like to buy?: ").strip().title()
if choice in items:
if items[choice][1]>0:
if stash>=items[choice][0]:
items[choice][1]=items[choice][1]-1
stash= stash-items[choice][0]
await client.say("Thank you..!")
await client.say("")
else:
await client.say("Sorry you dont enough money...")
await client.say("")
else:
await client.say("sorry sold out")
await client.say("")
else:
await client.say("Sorry we don't have that item...")
await client.say("")