我的功能是没有给我正确的输出,它不想工作.我一直收到这个错误:
TypeError: list indices must be integers, not str
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
def showShop(level = level, cash = cash):
top = Tkinter.Tk()
shop = ["$100 & level 2 - Shotgun", "$250 & level 3 - 5 Grenades", "$500 & level 5 - Rocket Launcher"]
buttons = []
for i in shop:
temp = shop[i]
temp = Tkinter.Button(top, height=10, width=100, text = temp, command = shopping(i))
temp.pack()
buttons.append(temp)
top.mainloop()
Run Code Online (Sandbox Code Playgroud)
我希望它根据它是什么按钮显示商店列表中的内容...