Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/358.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python在尝试获取tkinter条目值时出错_Python_Tkinter_Tkinter Entry - Fatal编程技术网

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

我正在尝试用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(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)
...