更新时间2022-08-04 08:31:51
指令如下:from tkinter import *root = Tk()root.title('calculator')a = Variable()e1 = Entry(root,width=28,bd=0,textvariable=a)e1.place(x=0,y=0)def a(): a.set(1)Button(root,text='1',width=3,height=1,bd=1,command=a).place(x=0,y=20)root.mainloop()每次点击按钮时老是报错:AttributeError: 'function' object has no attribute 'set'(Python3.7)
你的a既定义了变量,又把它定义成了函数,当然是不对的,改函数为其它的如b就可以了