【发布时间】:2019-05-26 01:26:35
【问题描述】:
如何将 creatLabels 函数中的 (Answer) 变量传递给检查函数?
def createLabels(Ques):
AnswerINP = Entry(root)
AnswerINP.grid(column=3, sticky=W )
Answer = AnswerINP.get()
Checkbutton = tk.Button(root, text="CHECK", command= check)
Checkbutton.grid()
def check ():
r=requests.get('https://opentdb.com/api.phpamount='+TextINP1.get()+'&difficul)
res = r.json ()
for data in res ['results']:
if Answer.title()== data["correct_answer"]:
print("Correct")
当我以这种方式编写时,我得到那个变量答案没有定义
【问题讨论】:
标签: python function variables tkinter