我写的唯一代码导致错误。有任何想法吗? 这是我的错误:
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()
答案 0 :(得分:2)
在python 2中,将import tkinter
替换为import Tkinter
,使用大写T
from Tkinter import *
root = Tk()
root.mainloop()