python tkinter的button问题

2025-03-13 06:50:35
推荐回答(1个)
回答1:

不知到你的tkinter版本是啥?
import Tkinter #首字母大写

def hello():
print(i)

top = Tkinter.Tk()
for i in range(0, 4):
Tkinter.Button(top, text=i, command=hello).grid(row=1, column=i)
top.mainloop()

我打印的是0,1,2,3.

如果解决了您的问题请采纳!
如果未解决请继续追问