python中怎么显示图片
时间: 2023-05-27 09:08:08 浏览: 113
Python中可以使用Pillow库(Python Imaging Library的一个分支)来显示图片。具体步骤如下:
1. 安装Pillow库
```
pip install pillow
```
2. 导入Pillow库
```python
from PIL import Image
```
3. 打开图片
```python
img = Image.open('path/to/image.jpg')
```
4. 显示图片
```python
img.show()
```
完整代码示例:
```python
from PIL import Image
img = Image.open('path/to/image.jpg')
img.show()
```
注意:`img.show()`函数调用后会打开一个新窗口来显示图片,如果你需要在Python程序中显示图片,可以使用Matplotlib库的imshow函数来代替。
阅读全文
相关推荐















