AttributeError: module 'tkinter' has no attribute 'messagebox'
时间: 2023-09-20 07:03:37 浏览: 47
This error occurs when you try to use the `messagebox` module from `tkinter` but it is not available in your version of `tkinter`.
To fix this error, you can try updating your version of `tkinter` or you can use an alternative package such as `tkinter.messagebox` or `tkinter.simpledialog`.
Here's an example of how to use `tkinter.messagebox`:
```python
import tkinter as tk
from tkinter import messagebox
root = tk.Tk()
root.withdraw()
messagebox.showinfo('Title', 'This is the message')
```
If you still encounter the error, you can try importing `tkinter.simpledialog` instead:
```python
import tkinter as tk
import tkinter.simpledialog as simpledialog
root = tk.Tk()
root.withdraw()
user_input = simpledialog.askstring(title='Title', prompt='Enter input')
```
相关推荐
![py](https://img-home.csdnimg.cn/images/20210720083646.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)