未解决的参考文献' tkinter'

时间:2017-10-02 15:04:01

标签: python tkinter

我写的唯一代码导致错误。有任何想法吗? 这是我的错误:

C:\Python27\python.exe "C:/Users/Robert/Desktop/Roberts' Python/AB-Windows.py"
Traceback (most recent call last):
  File "C:/Users/Robert/Desktop/Roberts' Python/AB-Windows.py", line 1, in <module>
    from tkinter import *
ImportError: No module named tkinter

以下是代码:

from tkinter import *

root = Tk()
root.mainloop()

1 个答案:

答案 0 :(得分:2)

在python 2中,将import tkinter替换为import Tkinter,使用大写T

from Tkinter import *

root = Tk()

root.mainloop()