如何在Python 2.7.5中获取消息框 >>从Tkinter导入tkMessageBox 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 从Tkinter导入tkMessageBox ImportError:无法导入名称tkMessageBox

如何在Python 2.7.5中获取消息框 >>从Tkinter导入tkMessageBox 回溯(最近一次呼叫最后一次): 文件“”,第1行,在 从Tkinter导入tkMessageBox ImportError:无法导入名称tkMessageBox,python,python-2.7,tkinter,Python,Python 2.7,Tkinter,即使Tkinter import*的工作正常,我还是收到了这个错误。我使用的是Python 2.7.5。tkMessageBox本身就是一个模块,因此您应该单独导入它: >>> from Tkinter import tkMessageBox Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> from Tkinter import tkMes

即使Tkinter import*的
工作正常,我还是收到了这个错误。我使用的是Python 2.7.5。

tkMessageBox
本身就是一个模块,因此您应该单独导入它:

>>> from Tkinter import tkMessageBox

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    from Tkinter import tkMessageBox
ImportError: cannot import name tkMessageBox
import Tkinter 
import tkMessageBox