python在尝试获取tkinter条目值时出错
我正在尝试用python打印tkinter条目值 像这样python在尝试获取tkinter条目值时出错,python,tkinter,tkinter-entry,Python,Tkinter,Tkinter Entry,我正在尝试用python打印tkinter条目值 像这样 from tkinter import * root=Tk() root.geometry("500x500") def temperature(): print(celciusEntry.get()) farenheidLabel = Label(root, text = "farenheid").place(x=110, y=10) farenheidAnswer = Label(r
from tkinter import *
root=Tk()
root.geometry("500x500")
def temperature():
print(celciusEntry.get())
farenheidLabel = Label(root, text = "farenheid").place(x=110, y=10)
farenheidAnswer = Label(root, text="=",).place(x=110, y=30)
celciusLabel = Label(root, text="celcuis").place(x=20, y=10)
celciusEntry = Entry(root, width=10,).place(x=20, y=30)
temperaturebtn=Button(root, height=1, text="convert temperature", command=lambda:temperature())
temperaturebtn.place(x=20,y=100)
mainloop()
但是我得到一个错误,说对象没有属性“get”
为什么我会得到这个错误。更改:
...
celciusEntry = Entry(root, width=10).place(x=20, y=30)
...
到
...
celciusEntry = Entry(root, width=10)
celciusEntry.place(x=20, y=30)
...