for循环如下所示(列表words = ["box1", "box2", ..., "box100"]
):
for i in words:
a = a + 1
i = tk.Button(window2, text = a, command = btn_press)
i.config(height = '3', width = '5')
i.place(x = -50 + a * 70, y = 25)
我还有一个随机生成的数字,并将其存储为“ boxX”。 问题是当我尝试执行以下操作时:
def btn_press():
guess = i['text']
if guess == target:
system('say you win!')
变量猜测总是框100(也许因为它是for循环创建的最后一个?)。请告诉我,我不必手动做100箱。