美文网首页
004萝卜头学python:GUI tkinter :modul

004萝卜头学python:GUI tkinter :modul

作者: 萝卜头科技 | 来源:发表于2020-04-05 14:55 被阅读0次

萝卜头社区 http://www.luobotou.net 同学反映, 实用tkinter 时,报错:

代码:

import tkinter as tk
window=tk.Tk()
window.title("你好")
window.mainloop() 

错误提示如下:

app=tk.Tk()
AttributeError: module 'tkinter' has no attribute 'Tk'

原因:

其把Python的GUI程序命名成tkinter,其后来另存为其他名字后,但原来目录里其命名为tkinter的程序还在。

所以只要命名成这个,一调用就会报这个错。

解决:把这个问题文件重命名,把对应的*.pyd文件也删除,OK。

相关文章

网友评论

      本文标题:004萝卜头学python:GUI tkinter :modul

      本文链接:https://www.haomeiwen.com/subject/loyuphtx.html