Day2-1测试积点任务
问题:python导入tkinter后运行代码提示tk未定义
<font face="微软雅黑" size="3"># -*- encoding:utf-8 -*-
from tkinterimport *
import tkinter.simpledialog as dl
import tkinter.messagebox as mb
win=TK()
w=tkinter.Label(win,text="Guess Number Game")
w.pack()
mb.showinfo("welcome to guess number game")
number=88
while True:
guess=dl.askinteger("Number","what's your number")
if guess==number:
output="bingo! you are right,but you do not win any prize!"
mb.showinfo("result",output)
elif guess<number:
output="no ,the number is a lower than that"
mb.showinfo("result",output)
else :
output="no,the number is a higher than that"
mb.showinfo("result",output)
print("done!")
</font>
运行上述代码,提示
<font face="微软雅黑" size="3">Traceback (most recent call last):
File "tk1.py", line 5, in <module>
win=TK()
NameError: name 'TK' is not defined</font>
安装python3.6版本,,上面问题该怎么解决?初学python有很多不懂的地方,希望大家能
够不吝赐教,谢谢!
除了提示为定义还有其他的么
报错图记得贴一下 引入下tkinter的完整包 是不是有点依赖包之类的 缺少东西么? 查看一下日志,应该是缺乏依赖包 from Tkinter import *
页:
[1]