【发布时间】:2019-08-07 01:16:49
【问题描述】:
我对 python 有点陌生,但我知道变量和字符串等基础知识,我最近创建了一个包含货币和商店的不和谐机器人。这家商店不工作,它的意思是让我为列出的物品买一张票(它不是为了存储任何东西)。请你帮我找出我哪里出错并帮助我改善或给我看我哪里出错了哪里可以找到我的答案。这是我为商店买的(注意我使用的是 python 3.6.4):
@client.command(pass_context = True)
async def buy(ctx, item):
items = {
"Apex Legends":[3,20],
"Minecraft":[5,30],
"Halo":[5,20],
"Fortnite":[8,10],
}
while True:
print("Apex Legends = 3BP / Minecraft = 5BP / Halo = 5BP / Fortnite = 8BP")
print("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]
print("Thank you..!")
print("")
else:
print("Sorry you don\'t enough money...")
print("")
else:
print("sorry sold out")
print("")
else:
print("Sorry we don\'t have that item...")
print("")
如果您想在机器人上查看我的完整代码,请点击此处: https://hastebin.com/tojadefajo.py
【问题讨论】:
-
您的代码的具体错误或意外响应是什么?
-
当我启动机器人时,我的其他命令都不起作用,当我查看控制台时,它显示了我能做什么,但是在不和谐时,我希望它显示在不和谐而不是控制台上
标签: python python-3.x bots