【发布时间】:2020-02-29 20:33:45
【问题描述】:
当我尝试使用 .get() 从 python 中的输入框中收集数据时,它返回为AttributeError: 'NoneType' object has no attribute 'get' 无论我尝试什么它都不起作用。谢谢,需要我能得到的所有帮助。
def PETROL():
Petrol = Tk()
petrol = Label(Petrol, width=20, text="Petrol", font=30).grid(row=0, column=0)
PEtrol = Label(Petrol, width=50, text="Enter how much Petrol you have bought in litres.", font=20).grid(row=1, column=0)
c = Entry(Petrol, width=50, bg="grey", fg="white", borderwidth=4).grid(row=2, column=0)
Seperator7 = Label(Petrol, text=" ", width=46, height=2).grid(row=3, column=0, columnspan=2)
c.get()
d = c.get()
Petrol.mainloop()
【问题讨论】:
-
代码在哪里?
-
原因是——你的
c是None,所以你的Entry(Petrol(...).grid(...)返回None。