TypeError() missing 1 required positional argument: 'event'or: <lambda>

引起错误的代码就在下面,先贴代码

if __name__=='__main__':
    root=Tk()
    ents=makeform(root,fileds)
    root.bind('<Return>',(lambda event:fetch(ents)))
    Button(root,text='fetch',command=(lambda event:fetch(ents))).pack()
    Quitter(root).pack()
    root.mainloop()

然后报的错误就是TypeError() missing 1 required positional argument: ‘event’or:
实际上引起错误的是
Button(root,text=’fetch’,command=(lambda event:fetch(ents))).pack()
只需要改成 Button(root,text=’fetch’,command=(lambda :fetch(ents))).pack()
对,就是删除那个event就可以了,至于为什么,暂时还不知道,鉴于我还是初学者也就不在这里胡说八道了,以后搞清楚原因会再来更新

猜你喜欢

转载自blog.csdn.net/c2496649361/article/details/80869096